| 787 | } |
| 788 | |
| 789 | const runImpl = <K, A, E, R, XE extends E, XA extends A>( |
| 790 | self: FiberMap<K, A, E>, |
| 791 | key: K, |
| 792 | effect: Effect.Effect<XA, XE, R>, |
| 793 | options?: { |
| 794 | readonly onlyIfMissing?: boolean |
| 795 | readonly propagateInterruption?: boolean | undefined |
| 796 | } |
| 797 | ) => |
| 798 | Effect.withFiber((parent) => { |
| 799 | if (self.state._tag === "Closed") { |
| 800 | return Effect.interrupt |
| 801 | } else if (options?.onlyIfMissing === true && hasUnsafe(self, key)) { |
| 802 | return Effect.sync(constInterruptedFiber) |
| 803 | } |
| 804 | const fiber = Effect.runForkWith(parent.context as Context<R>)(effect) |
| 805 | setUnsafe(self, key, fiber, options) |
| 806 | return Effect.succeed(fiber) |
| 807 | }) |
| 808 | |
| 809 | /** |
| 810 | * Captures the current runtime and returns a function for forking effects into |