MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / awaitCompletionOrPause

Function awaitCompletionOrPause

packages/core/execution/src/engine.ts:458–469  ·  view source on GitHub ↗
(
    fiber: Fiber.Fiber<ExecuteResult, E>,
    pauseQueue: Queue.Queue<InternalPausedExecution<E>>,
  )

Source from the content-addressed store, hash-verified

456 * settles on whichever side completes first, success or failure.
457 */
458 const awaitCompletionOrPause = (
459 fiber: Fiber.Fiber<ExecuteResult, E>,
460 pauseQueue: Queue.Queue<InternalPausedExecution<E>>,
461 ): Effect.Effect<ExecutionResult, E> =>
462 Effect.raceFirst(
463 Fiber.join(fiber).pipe(
464 Effect.map((result): ExecutionResult => ({ status: "completed", result })),
465 ),
466 Queue.take(pauseQueue).pipe(
467 Effect.map((paused): ExecutionResult => ({ status: "paused", execution: paused })),
468 ),
469 );
470
471 /**
472 * Start an execution in pause/resume mode.

Callers 1

createExecutionEngineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected