* Begins execution of the effect associated with this fiber on the current * thread. This can be called to "kick off" execution of a fiber after it has * been created, in hopes that the effect can be executed synchronously. * * This is not the normal way of starting a fiber, but it is us
(effect: Effect.Effect<A, E, R>)
| 996 | * express goal of executing the fiber is to synchronously produce its exit. |
| 997 | */ |
| 998 | start<R>(effect: Effect.Effect<A, E, R>): void { |
| 999 | if (!this._running) { |
| 1000 | this._running = true |
| 1001 | const prev = (globalThis as any)[internalFiber.currentFiberURI] |
| 1002 | ;(globalThis as any)[internalFiber.currentFiberURI] = this |
| 1003 | try { |
| 1004 | this.evaluateEffect(effect) |
| 1005 | } finally { |
| 1006 | this._running = false |
| 1007 | ;(globalThis as any)[internalFiber.currentFiberURI] = prev |
| 1008 | // Because we're special casing `start`, we have to be responsible |
| 1009 | // for spinning up the fiber if there were new messages added to |
| 1010 | // the queue between the completion of the effect and the transition |
| 1011 | // to the not running state. |
| 1012 | if (this._queue.length > 0) { |
| 1013 | this.drainQueueLaterOnExecutor() |
| 1014 | } |
| 1015 | } |
| 1016 | } else { |
| 1017 | this.tell(FiberMessage.resume(effect)) |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * Begins execution of the effect associated with this fiber on in the |