* Returns an effect that will contain information computed from the fiber * state and status while running on the fiber. * * This allows the outside world to interact safely with mutable fiber state * without locks or immutable data.
(
f: (runtime: FiberRuntime<any, any>, status: FiberStatus.FiberStatus) => Z
)
| 424 | * without locks or immutable data. |
| 425 | */ |
| 426 | ask<Z>( |
| 427 | f: (runtime: FiberRuntime<any, any>, status: FiberStatus.FiberStatus) => Z |
| 428 | ): Effect.Effect<Z> { |
| 429 | return core.suspend(() => { |
| 430 | const deferred = core.deferredUnsafeMake<Z>(this._fiberId) |
| 431 | this.tell( |
| 432 | FiberMessage.stateful((fiber, status) => { |
| 433 | core.deferredUnsafeDone(deferred, core.sync(() => f(fiber, status))) |
| 434 | }) |
| 435 | ) |
| 436 | return core.deferredAwait(deferred) |
| 437 | }) |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Adds a message to be processed by the fiber on the fiber. |