MCPcopy Index your code
hub / github.com/Effect-TS/effect / unsafeOffer

Method unsafeOffer

packages/effect/src/internal/queue.ts:152–178  ·  view source on GitHub ↗
(value: A)

Source from the content-addressed store, hash-verified

150 }
151
152 unsafeOffer(value: A): boolean {
153 if (MutableRef.get(this.shutdownFlag)) {
154 return false
155 }
156 let noRemaining: boolean
157 if (this.queue.length() === 0) {
158 const taker = pipe(
159 this.takers,
160 MutableQueue.poll(MutableQueue.EmptyMutableQueue)
161 )
162 if (taker !== MutableQueue.EmptyMutableQueue) {
163 unsafeCompleteDeferred(taker, value)
164 noRemaining = true
165 } else {
166 noRemaining = false
167 }
168 } else {
169 noRemaining = false
170 }
171 if (noRemaining) {
172 return true
173 }
174 // Not enough takers, offer to the queue
175 const succeeded = this.queue.offer(value)
176 unsafeCompleteTakers(this.strategy, this.queue, this.takers)
177 return succeeded
178 }
179
180 offer(value: A): Effect.Effect<boolean> {
181 return core.suspend(() => {

Callers

nothing calls this directly

Calls 6

pipeFunction · 0.70
unsafeCompleteDeferredFunction · 0.70
getMethod · 0.65
lengthMethod · 0.65
pollMethod · 0.65
offerMethod · 0.65

Tested by

no test coverage detected