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

Function queuedScheduler

packages/effect/test/Semaphore.test.ts:388–406  ·  view source on GitHub ↗
(
        tasks: Array<() => void>,
        onOperation: (fiber: Fiber.Fiber<unknown, unknown>) => void
      )

Source from the content-addressed store, hash-verified

386 it.effect("queued withPermits interrupted at any operation does not leak permits", () =>
387 Effect.gen(function*() {
388 const queuedScheduler = (
389 tasks: Array<() => void>,
390 onOperation: (fiber: Fiber.Fiber<unknown, unknown>) => void
391 ) => {
392 const scheduler: Scheduler.Scheduler = {
393 executionMode: "async",
394 makeDispatcher: () => ({
395 scheduleTask(task) {
396 tasks.push(task)
397 },
398 flush() {}
399 }),
400 shouldYield: (fiber) => {
401 onOperation(fiber)
402 return false
403 }
404 }
405 return scheduler
406 }
407
408 let operations = 0
409 const baselineSem = yield* Semaphore.make(1)

Callers 1

Semaphore.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected