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

Function canTake

packages/effect/src/Queue.ts:2077–2079  ·  view source on GitHub ↗
(self: Dequeue<A, E>, min: number)

Source from the content-addressed store, hash-verified

2075// Whether a take of at least `min` messages can complete without waiting.
2076// A closing queue receives no more messages, so any remainder satisfies `min`.
2077const canTake = <A, E>(self: Dequeue<A, E>, min: number): boolean =>
2078 self.messages.length >= (self.state._tag === "Closing" ? 1 : Math.min(min, self.capacity || 1)) ||
2079 (self.capacity <= 0 && self.state._tag !== "Done" && self.state.offers.size > 0)
2080
2081// The readiness check and the taker registration run in one step, so no
2082// message can arrive between them. Wake-ups resume with void and the caller

Callers 3

Queue.tsFile · 0.85
[core.evaluate]Function · 0.85
takeBetweenUnsafeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected