MCPcopy Create free account
hub / github.com/Effect-TS/effect / poll

Method poll

packages/effect/src/PubSub.ts:2179–2205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 }
2206
2207 pollUpTo(n: number): Array<A> {
2208 const builder: Array<A> = []

Callers 1

pollUpToMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected