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

Function awaitCompletionOrPause

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

Source from the content-addressed store, hash-verified

496 * settles on whichever side completes first, success or failure.
497 */
498 const awaitCompletionOrPause = (
499 fiber: Fiber.Fiber<ExecuteResult, E>,
500 pauseQueue: Queue.Queue<InternalPausedExecution<E>>,
501 ): Effect.Effect<ExecutionResult, E> =>
502 Effect.raceFirst(
503 Fiber.join(fiber).pipe(
504 Effect.map((result): ExecutionResult => ({ status: "completed", result })),
505 ),
506 Queue.take(pauseQueue).pipe(
507 Effect.map((paused): ExecutionResult => ({ status: "paused", execution: paused })),
508 ),
509 );
510
511 /**
512 * Start an execution in pause/resume mode.

Callers 1

createExecutionEngineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected