| 68 | SynchronizedRef.modify(ref, (st) => [st._tag === "Idle" ? idle : Effect.void, st] as const).pipe(Effect.flatten) |
| 69 | |
| 70 | const finishRun = (id: number, done: Deferred.Deferred<A, E | Cancelled>, exit: Exit.Exit<A, E>) => |
| 71 | SynchronizedRef.modify( |
| 72 | ref, |
| 73 | (st) => |
| 74 | [ |
| 75 | Effect.gen(function* () { |
| 76 | if (st._tag === "Running" && st.run.id === id) yield* idle |
| 77 | yield* complete(done, exit) |
| 78 | }), |
| 79 | st._tag === "Running" && st.run.id === id ? ({ _tag: "Idle" } as const) : st, |
| 80 | ] as const, |
| 81 | ).pipe(Effect.flatten) |
| 82 | |
| 83 | const startRun = (work: Effect.Effect<A, E>, done: Deferred.Deferred<A, E | Cancelled>) => |
| 84 | Effect.gen(function* () { |