| 2146 | this.subscriberIndex = subscriberIndex |
| 2147 | this.unsubscribed = unsubscribed |
| 2148 | } |
| 2149 | |
| 2150 | isEmpty(): boolean { |
| 2151 | if (this.unsubscribed) { |
| 2152 | return true |
| 2153 | } |
| 2154 | let empty = true |
| 2155 | let loop = true |
| 2156 | while (loop) { |
| 2157 | if (this.subscriberHead === this.self.publisherTail) { |
| 2158 | loop = false |
| 2159 | } else { |
| 2160 | if (this.subscriberHead.next!.value !== AbsentValue) { |
| 2161 | empty = false |
| 2162 | loop = false |
| 2163 | } else { |
| 2164 | this.subscriberHead = this.subscriberHead.next! |
| 2165 | this.subscriberIndex += 1 |
| 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | return empty |
| 2170 | } |
| 2171 | |
| 2172 | size() { |
| 2173 | if (this.unsubscribed) { |
| 2174 | return 0 |
| 2175 | } |
| 2176 | return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex) |
| 2177 | } |
| 2178 | |
| 2179 | poll(): A | MutableList.Empty { |
| 2180 | if (this.unsubscribed) { |
| 2181 | return MutableList.Empty |
| 2182 | } |
| 2183 | let loop = true |
| 2184 | let polled: A | MutableList.Empty = MutableList.Empty |
| 2185 | while (loop) { |
| 2186 | if (this.subscriberHead === this.self.publisherTail) { |
| 2187 | loop = false |
| 2188 | } else { |
| 2189 | const elem = this.subscriberHead.next!.value |
| 2190 | if (elem !== AbsentValue) { |
| 2191 | polled = elem |
| 2192 | this.subscriberHead.subscribers -= 1 |
| 2193 | if (this.subscriberHead.subscribers === 0) { |
| 2194 | this.self.publisherHead = this.self.publisherHead.next! |
| 2195 | this.self.publisherHead.value = AbsentValue |
| 2196 | this.self.subscribersIndex += 1 |
| 2197 | } |
| 2198 | loop = false |
| 2199 | } |
| 2200 | this.subscriberHead = this.subscriberHead.next! |
| 2201 | this.subscriberIndex += 1 |
| 2202 | } |
| 2203 | } |
| 2204 | return polled |
| 2205 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…