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

Function wakeWaiters

packages/effect/src/Pool.ts:808–823  ·  view source on GitHub ↗
(self: Pool<A, E>, fiber: Fiber.Fiber<unknown, unknown>, count: number)

Source from the content-addressed store, hash-verified

806 }, self)
807
808const wakeWaiters = <A, E>(self: Pool<A, E>, fiber: Fiber.Fiber<unknown, unknown>, count: number) => {
809 const waiters = self.state.waiters
810 if (waiters.size === 0) return
811 fiber.currentDispatcher.scheduleTask(() => {
812 // Walk the live set, so a waiter that leaves during the walk does not use
813 // up a wake. Skip waiters already woken, and stop once nothing is left to
814 // take.
815 let remaining = count
816 for (const notify of waiters) {
817 if (remaining <= 0 || self.state.availableHead === undefined) break
818 if ((notify as Waiter<A, E>).resume === undefined) continue
819 remaining--
820 notify()
821 }
822 }, 0)
823}
824
825const firstSleepingWaiter = <A, E>(self: Pool<A, E>) => {
826 for (const notify of self.state.waiters) {

Callers 5

getSlowWithFunction · 0.85
makeReturnLeaseFunction · 0.85
Pool.tsFile · 0.85
resizeLoopFunction · 0.85
allocateFunction · 0.85

Calls 2

notifyFunction · 0.70
scheduleTaskMethod · 0.65

Tested by

no test coverage detected