MCPcopy
hub / github.com/Effect-TS/effect / shutdown

Method shutdown

packages/effect/src/internal/pool.ts:317–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

315 }
316
317 get shutdown(): Effect<void> {
318 return core.suspend(() => {
319 if (this.isShuttingDown) return core.void
320 this.isShuttingDown = true
321 const size = this.items.size
322 const semaphore = circular.unsafeMakeSemaphore(size)
323 return core.forEachSequentialDiscard(this.items, (item) => {
324 if (item.refCount > 0) {
325 item.finalizer = core.zipLeft(item.finalizer, semaphore.release(1))
326 this.invalidated.add(item)
327 return semaphore.take(1)
328 }
329 this.items.delete(item)
330 this.available.delete(item)
331 this.invalidated.delete(item)
332 return item.finalizer
333 }).pipe(
334 core.zipRight(this.semaphore.releaseAll),
335 core.zipRight(this.availableLatch.open),
336 core.zipRight(semaphore.take(size))
337 )
338 })
339 }
340
341 pipe() {
342 return pipeArguments(this, arguments)

Callers 15

raceFunction · 0.45
_asyncFunction · 0.45
asyncEffectFunction · 0.45
asyncScopedFunction · 0.45
stream.tsFile · 0.45
fromChunkPubSubFunction · 0.45
fromChunkQueueFunction · 0.45
fromPubSubFunction · 0.45
fromQueueFunction · 0.45
channel.tsFile · 0.45
mergeAllWithFunction · 0.45
subscribeScopedFunction · 0.45

Calls 4

releaseMethod · 0.80
pipeMethod · 0.65
addMethod · 0.65
takeMethod · 0.65

Tested by

no test coverage detected