| 1815 | this.unsubscribed || |
| 1816 | this.self.publisherIndex === this.subscriberIndex || |
| 1817 | this.self.publisherIndex === this.self.subscribersIndex |
| 1818 | ) |
| 1819 | } |
| 1820 | |
| 1821 | size() { |
| 1822 | if (this.unsubscribed) { |
| 1823 | return 0 |
| 1824 | } |
| 1825 | return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex) |
| 1826 | } |
| 1827 | |
| 1828 | poll(): A | MutableList.Empty { |
| 1829 | if (this.unsubscribed) { |
| 1830 | return MutableList.Empty |
| 1831 | } |
| 1832 | this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex) |
| 1833 | if (this.subscriberIndex !== this.self.publisherIndex) { |
| 1834 | const index = this.subscriberIndex & this.self.mask |
| 1835 | const elem = this.self.array[index]! |
| 1836 | this.self.subscribers[index] -= 1 |
| 1837 | if (this.self.subscribers[index] === 0) { |
| 1838 | this.self.array[index] = AbsentValue as unknown as A |
| 1839 | this.self.subscribersIndex += 1 |
| 1840 | } |
| 1841 | this.subscriberIndex += 1 |
| 1842 | return elem |
| 1843 | } |
| 1844 | return MutableList.Empty |
| 1845 | } |
| 1846 | |
| 1847 | pollUpTo(n: number): Array<A> { |
| 1848 | if (this.unsubscribed) { |
| 1849 | return [] |
| 1850 | } |
| 1851 | this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex) |
| 1852 | const size = this.self.publisherIndex - this.subscriberIndex |
| 1853 | const toPoll = Math.min(n, size) |
| 1854 | if (toPoll <= 0) { |
| 1855 | return [] |
| 1856 | } |
| 1857 | const builder: Array<A> = [] |
| 1858 | const pollUpToIndex = this.subscriberIndex + toPoll |
| 1859 | while (this.subscriberIndex !== pollUpToIndex) { |
| 1860 | const index = this.subscriberIndex & this.self.mask |
| 1861 | const elem = this.self.array[index] as A |
| 1862 | this.self.subscribers[index] -= 1 |
| 1863 | if (this.self.subscribers[index] === 0) { |
| 1864 | this.self.array[index] = AbsentValue as unknown as A |
| 1865 | this.self.subscribersIndex += 1 |
| 1866 | } |
| 1867 | builder.push(elem) |
| 1868 | this.subscriberIndex += 1 |
| 1869 | } |
| 1870 | return builder |
| 1871 | } |
| 1872 | |
| 1873 | unsubscribe(): void { |
| 1874 | if (!this.unsubscribed) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…