@fncts/io 0.0.48 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cached/api.d.ts +1 -1
- package/Channel/api.d.ts +80 -80
- package/Channel/core-api.d.ts +26 -26
- package/Console/definition.d.ts +1 -0
- package/CountdownLatch.d.ts +1 -0
- package/Fiber/FiberMessage.d.ts +6 -28
- package/Fiber/FiberRuntime.d.ts +108 -77
- package/Fiber/api/interruptAs.d.ts +2 -2
- package/Fiber/definition.d.ts +2 -0
- package/FiberScope/definition.d.ts +3 -0
- package/FiberSet.d.ts +2 -1
- package/Future/State.d.ts +59 -0
- package/Future/api.d.ts +8 -3
- package/Future/constructors.d.ts +1 -1
- package/Future/definition.d.ts +1 -17
- package/Future.d.ts +1 -0
- package/Hub/api.d.ts +15 -15
- package/IO/api/array.d.ts +22 -0
- package/IO/api/awaitAllChildren.d.ts +6 -0
- package/IO/api/cachedInvalidate.d.ts +15 -0
- package/IO/api/foreachExec.d.ts +18 -0
- package/IO/api/forkDaemon.d.ts +1 -1
- package/IO/api/onTermination.d.ts +1 -2
- package/IO/api/transplant.d.ts +11 -1
- package/IO/api.d.ts +247 -225
- package/IO/definition.d.ts +12 -25
- package/IO.d.ts +3 -1
- package/Push/Bounds.d.ts +4 -0
- package/Push/FlattenStrategy.d.ts +47 -0
- package/Push/IndexedBuffer.d.ts +19 -0
- package/Push/MergeStrategy.d.ts +19 -0
- package/Push/Operator/IOLoopOperator.d.ts +61 -0
- package/Push/Operator/IOOperator.d.ts +63 -0
- package/Push/Operator/LoopOperator.d.ts +50 -0
- package/Push/Operator/SyncOperator.d.ts +41 -0
- package/Push/Operator.d.ts +4 -0
- package/Push/Producer/IOProducer.d.ts +41 -0
- package/Push/Producer/SyncProducer.d.ts +61 -0
- package/Push/Producer.d.ts +1 -0
- package/Push/Sink.d.ts +65 -0
- package/Push/api.d.ts +78 -161
- package/Push/definition.d.ts +92 -19
- package/Push/internal.d.ts +3 -0
- package/Push.d.ts +6 -0
- package/Random/definition.d.ts +1 -0
- package/Ref/Synchronized/api.d.ts +1 -1
- package/Ref/Synchronized/definition.d.ts +32 -9
- package/Ref/definition.d.ts +12 -0
- package/Scope/api.d.ts +16 -1
- package/Semaphore/Reservation.d.ts +15 -0
- package/Semaphore/constructors.d.ts +13 -0
- package/Semaphore/definition.d.ts +29 -0
- package/Semaphore.d.ts +3 -40
- package/Sink/definition.d.ts +5 -6
- package/Stream/api.d.ts +164 -164
- package/Subject/Atomic.d.ts +19 -9
- package/Subject/DeferredRef.d.ts +17 -0
- package/Subject/Hold.d.ts +19 -0
- package/Subject/RefSubject/Atomic.d.ts +41 -0
- package/Subject/RefSubject/Derived.d.ts +43 -0
- package/Subject/RefSubject/RefSubject.d.ts +27 -0
- package/Subject/definition.d.ts +14 -2
- package/Subject.d.ts +2 -0
- package/SubscriptionRef.d.ts +0 -1
- package/_cjs/Cached/api.cjs +1 -2
- package/_cjs/Cached/api.cjs.map +1 -1
- package/_cjs/Cached/internal.cjs +1 -2
- package/_cjs/Cached/internal.cjs.map +1 -1
- package/_cjs/Channel/api/interruptWhen.cjs +1 -2
- package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +2 -3
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAll.cjs +1 -2
- package/_cjs/Channel/api/mergeAll.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +1 -2
- package/_cjs/Channel/api/mergeAllUnboundedWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +2 -3
- package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
- package/_cjs/Channel/api/mergeMap.cjs +1 -2
- package/_cjs/Channel/api/mergeMap.cjs.map +1 -1
- package/_cjs/Channel/api/mergeWith.cjs +1 -2
- package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
- package/_cjs/Channel/api/run.cjs +1 -2
- package/_cjs/Channel/api/run.cjs.map +1 -1
- package/_cjs/Channel/api/runCollect.cjs +1 -2
- package/_cjs/Channel/api/runCollect.cjs.map +1 -1
- package/_cjs/Channel/api/runDrain.cjs +1 -2
- package/_cjs/Channel/api/runDrain.cjs.map +1 -1
- package/_cjs/Channel/api/runScoped.cjs +3 -4
- package/_cjs/Channel/api/runScoped.cjs.map +1 -1
- package/_cjs/Channel/api/toPull.cjs +2 -3
- package/_cjs/Channel/api/toPull.cjs.map +1 -1
- package/_cjs/Channel/api/zipConcurrent.cjs +1 -2
- package/_cjs/Channel/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/Channel/api.cjs +206 -207
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/core-api.cjs +43 -42
- package/_cjs/Channel/core-api.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +4 -5
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelState.cjs +1 -2
- package/_cjs/Channel/internal/ChannelState.cjs.map +1 -1
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +1 -2
- package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
- package/_cjs/Clock/api.cjs +1 -2
- package/_cjs/Clock/api.cjs.map +1 -1
- package/_cjs/Clock/definition.cjs +1 -2
- package/_cjs/Clock/definition.cjs.map +1 -1
- package/_cjs/Clock/live.cjs +1 -2
- package/_cjs/Clock/live.cjs.map +1 -1
- package/_cjs/Console/api.cjs +1 -2
- package/_cjs/Console/api.cjs.map +1 -1
- package/_cjs/Console/definition.cjs +2 -2
- package/_cjs/Console/definition.cjs.map +1 -1
- package/_cjs/Console/live.cjs +1 -2
- package/_cjs/Console/live.cjs.map +1 -1
- package/_cjs/CountdownLatch.cjs +3 -3
- package/_cjs/CountdownLatch.cjs.map +1 -1
- package/_cjs/Differ/api.cjs +1 -2
- package/_cjs/Differ/api.cjs.map +1 -1
- package/_cjs/Fiber/FiberMessage.cjs +3 -24
- package/_cjs/Fiber/FiberMessage.cjs.map +1 -1
- package/_cjs/Fiber/FiberRuntime.cjs +879 -636
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
- package/_cjs/Fiber/api/awaitAll.cjs +1 -2
- package/_cjs/Fiber/api/awaitAll.cjs.map +1 -1
- package/_cjs/Fiber/api/collectAll.cjs +2 -3
- package/_cjs/Fiber/api/collectAll.cjs.map +1 -1
- package/_cjs/Fiber/api/fromIO.cjs +1 -2
- package/_cjs/Fiber/api/fromIO.cjs.map +1 -1
- package/_cjs/Fiber/api/interrupt.cjs +2 -3
- package/_cjs/Fiber/api/interrupt.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAll.cjs +2 -3
- package/_cjs/Fiber/api/interruptAll.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptAs.cjs +5 -10
- package/_cjs/Fiber/api/interruptAs.cjs.map +1 -1
- package/_cjs/Fiber/api/interruptFork.cjs +2 -3
- package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
- package/_cjs/Fiber/api/join.cjs +1 -2
- package/_cjs/Fiber/api/join.cjs.map +1 -1
- package/_cjs/Fiber/api/joinAll.cjs +1 -2
- package/_cjs/Fiber/api/joinAll.cjs.map +1 -1
- package/_cjs/Fiber/api/mapFiber.cjs +1 -2
- package/_cjs/Fiber/api/mapFiber.cjs.map +1 -1
- package/_cjs/Fiber/api/mapIO.cjs +2 -3
- package/_cjs/Fiber/api/mapIO.cjs.map +1 -1
- package/_cjs/Fiber/api/zipWith.cjs +2 -3
- package/_cjs/Fiber/api/zipWith.cjs.map +1 -1
- package/_cjs/Fiber/constructors.cjs +2 -3
- package/_cjs/Fiber/constructors.cjs.map +1 -1
- package/_cjs/Fiber/definition.cjs +6 -4
- package/_cjs/Fiber/definition.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScoped.cjs +1 -2
- package/_cjs/FiberRef/api/locallyScoped.cjs.map +1 -1
- package/_cjs/FiberRef/api/locallyScopedWith.cjs +1 -2
- package/_cjs/FiberRef/api/locallyScopedWith.cjs.map +1 -1
- package/_cjs/FiberRef/constructors.cjs +1 -2
- package/_cjs/FiberRef/constructors.cjs.map +1 -1
- package/_cjs/FiberRef/definition.cjs +1 -2
- package/_cjs/FiberRef/definition.cjs.map +1 -1
- package/_cjs/FiberRef/operations.cjs +1 -2
- package/_cjs/FiberRef/operations.cjs.map +1 -1
- package/_cjs/FiberRef/unsafe.cjs +1 -2
- package/_cjs/FiberRef/unsafe.cjs.map +1 -1
- package/_cjs/FiberRefs/Patch.cjs +1 -2
- package/_cjs/FiberRefs/Patch.cjs.map +1 -1
- package/_cjs/FiberRefs/api.cjs +1 -2
- package/_cjs/FiberRefs/api.cjs.map +1 -1
- package/_cjs/FiberRefs/definition.cjs +1 -2
- package/_cjs/FiberRefs/definition.cjs.map +1 -1
- package/_cjs/FiberScope/definition.cjs +29 -6
- package/_cjs/FiberScope/definition.cjs.map +1 -1
- package/_cjs/FiberSet.cjs +16 -15
- package/_cjs/FiberSet.cjs.map +1 -1
- package/_cjs/FiberStatus/definition.cjs +1 -2
- package/_cjs/FiberStatus/definition.cjs.map +1 -1
- package/_cjs/Future/State.cjs +108 -0
- package/_cjs/Future/State.cjs.map +1 -0
- package/_cjs/Future/api.cjs +71 -64
- package/_cjs/Future/api.cjs.map +1 -1
- package/_cjs/Future/constructors.cjs +3 -4
- package/_cjs/Future/constructors.cjs.map +1 -1
- package/_cjs/Future/definition.cjs +1 -15
- package/_cjs/Future/definition.cjs.map +1 -1
- package/_cjs/Future.cjs +11 -0
- package/_cjs/Future.cjs.map +1 -1
- package/_cjs/Hub/api.cjs +56 -57
- package/_cjs/Hub/api.cjs.map +1 -1
- package/_cjs/Hub/internal.cjs +1 -2
- package/_cjs/Hub/internal.cjs.map +1 -1
- package/_cjs/IO/api/acquireRelease.cjs +1 -2
- package/_cjs/IO/api/acquireRelease.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseExit.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseExit.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseInterruptible.cjs.map +1 -1
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +1 -2
- package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizer.cjs +1 -2
- package/_cjs/IO/api/addFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/addFinalizerExit.cjs +1 -2
- package/_cjs/IO/api/addFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/all.cjs +1 -2
- package/_cjs/IO/api/all.cjs.map +1 -1
- package/_cjs/IO/api/array.cjs +51 -0
- package/_cjs/IO/api/array.cjs.map +1 -0
- package/_cjs/IO/api/asyncIO.cjs +1 -2
- package/_cjs/IO/api/asyncIO.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +1 -2
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
- package/_cjs/IO/api/awaitAllChildren.cjs +17 -0
- package/_cjs/IO/api/awaitAllChildren.cjs.map +1 -0
- package/_cjs/IO/api/blocking.cjs +1 -2
- package/_cjs/IO/api/blocking.cjs.map +1 -1
- package/_cjs/IO/api/bracket.cjs +1 -2
- package/_cjs/IO/api/bracket.cjs.map +1 -1
- package/_cjs/IO/api/bracketExit.cjs +1 -2
- package/_cjs/IO/api/bracketExit.cjs.map +1 -1
- package/_cjs/IO/api/cachedInvalidate.cjs +47 -0
- package/_cjs/IO/api/cachedInvalidate.cjs.map +1 -0
- package/_cjs/IO/api/clockWith.cjs +1 -2
- package/_cjs/IO/api/clockWith.cjs.map +1 -1
- package/_cjs/IO/api/concurrency.cjs +1 -2
- package/_cjs/IO/api/concurrency.cjs.map +1 -1
- package/_cjs/IO/api/concurrentFinalizers.cjs +1 -2
- package/_cjs/IO/api/concurrentFinalizers.cjs.map +1 -1
- package/_cjs/IO/api/consoleWith.cjs +1 -2
- package/_cjs/IO/api/consoleWith.cjs.map +1 -1
- package/_cjs/IO/api/daemonChildren.cjs +1 -2
- package/_cjs/IO/api/daemonChildren.cjs.map +1 -1
- package/_cjs/IO/api/delay.cjs +1 -2
- package/_cjs/IO/api/delay.cjs.map +1 -1
- package/_cjs/IO/api/descriptor.cjs +1 -2
- package/_cjs/IO/api/descriptor.cjs.map +1 -1
- package/_cjs/IO/api/diffFiberRefs.cjs +1 -2
- package/_cjs/IO/api/diffFiberRefs.cjs.map +1 -1
- package/_cjs/IO/api/disconnect.cjs +2 -3
- package/_cjs/IO/api/disconnect.cjs.map +1 -1
- package/_cjs/IO/api/ensuringChildren.cjs +1 -2
- package/_cjs/IO/api/ensuringChildren.cjs.map +1 -1
- package/_cjs/IO/api/environment.cjs +1 -2
- package/_cjs/IO/api/environment.cjs.map +1 -1
- package/_cjs/IO/api/foreachConcurrent.cjs +36 -30
- package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
- package/_cjs/IO/api/foreachExec.cjs +30 -6
- package/_cjs/IO/api/foreachExec.cjs.map +1 -1
- package/_cjs/IO/api/fork.cjs +2 -3
- package/_cjs/IO/api/fork.cjs.map +1 -1
- package/_cjs/IO/api/forkAll.cjs +1 -2
- package/_cjs/IO/api/forkAll.cjs.map +1 -1
- package/_cjs/IO/api/forkDaemon.cjs +5 -6
- package/_cjs/IO/api/forkDaemon.cjs.map +1 -1
- package/_cjs/IO/api/forkIn.cjs +1 -2
- package/_cjs/IO/api/forkIn.cjs.map +1 -1
- package/_cjs/IO/api/forkScoped.cjs +1 -2
- package/_cjs/IO/api/forkScoped.cjs.map +1 -1
- package/_cjs/IO/api/fulfill.cjs +1 -2
- package/_cjs/IO/api/fulfill.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +4 -5
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/memoize.cjs +1 -2
- package/_cjs/IO/api/memoize.cjs.map +1 -1
- package/_cjs/IO/api/onTermination.cjs +2 -3
- package/_cjs/IO/api/onTermination.cjs.map +1 -1
- package/_cjs/IO/api/once.cjs +1 -2
- package/_cjs/IO/api/once.cjs.map +1 -1
- package/_cjs/IO/api/patchFiberRefs.cjs +1 -2
- package/_cjs/IO/api/patchFiberRefs.cjs.map +1 -1
- package/_cjs/IO/api/provideLayer.cjs +1 -2
- package/_cjs/IO/api/provideLayer.cjs.map +1 -1
- package/_cjs/IO/api/provideScope.cjs +1 -2
- package/_cjs/IO/api/provideScope.cjs.map +1 -1
- package/_cjs/IO/api/provideSomeLayer.cjs +1 -2
- package/_cjs/IO/api/provideSomeLayer.cjs.map +1 -1
- package/_cjs/IO/api/provideSomeRuntime.cjs +1 -2
- package/_cjs/IO/api/provideSomeRuntime.cjs.map +1 -1
- package/_cjs/IO/api/race.cjs +2 -3
- package/_cjs/IO/api/race.cjs.map +1 -1
- package/_cjs/IO/api/raceFirst.cjs +1 -2
- package/_cjs/IO/api/raceFirst.cjs.map +1 -1
- package/_cjs/IO/api/raceWith.cjs +1 -2
- package/_cjs/IO/api/raceWith.cjs.map +1 -1
- package/_cjs/IO/api/randomWith.cjs +1 -2
- package/_cjs/IO/api/randomWith.cjs.map +1 -1
- package/_cjs/IO/api/repeat.cjs +1 -2
- package/_cjs/IO/api/repeat.cjs.map +1 -1
- package/_cjs/IO/api/retry.cjs +1 -2
- package/_cjs/IO/api/retry.cjs.map +1 -1
- package/_cjs/IO/api/schedule.cjs +1 -2
- package/_cjs/IO/api/schedule.cjs.map +1 -1
- package/_cjs/IO/api/scope.cjs +1 -2
- package/_cjs/IO/api/scope.cjs.map +1 -1
- package/_cjs/IO/api/scopeWith.cjs +1 -2
- package/_cjs/IO/api/scopeWith.cjs.map +1 -1
- package/_cjs/IO/api/scoped.cjs +1 -2
- package/_cjs/IO/api/scoped.cjs.map +1 -1
- package/_cjs/IO/api/sleep.cjs +1 -2
- package/_cjs/IO/api/sleep.cjs.map +1 -1
- package/_cjs/IO/api/stateful.cjs +1 -2
- package/_cjs/IO/api/stateful.cjs.map +1 -1
- package/_cjs/IO/api/supervised.cjs +1 -2
- package/_cjs/IO/api/supervised.cjs.map +1 -1
- package/_cjs/IO/api/timeout.cjs +9 -11
- package/_cjs/IO/api/timeout.cjs.map +1 -1
- package/_cjs/IO/api/transplant.cjs +22 -7
- package/_cjs/IO/api/transplant.cjs.map +1 -1
- package/_cjs/IO/api/whenFiberRef.cjs +1 -2
- package/_cjs/IO/api/whenFiberRef.cjs.map +1 -1
- package/_cjs/IO/api/whenRef.cjs +1 -2
- package/_cjs/IO/api/whenRef.cjs.map +1 -1
- package/_cjs/IO/api/withChildren.cjs +1 -2
- package/_cjs/IO/api/withChildren.cjs.map +1 -1
- package/_cjs/IO/api/withEarlyRelease.cjs +1 -2
- package/_cjs/IO/api/withEarlyRelease.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizer.cjs +1 -2
- package/_cjs/IO/api/withFinalizer.cjs.map +1 -1
- package/_cjs/IO/api/withFinalizerExit.cjs +1 -2
- package/_cjs/IO/api/withFinalizerExit.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +5 -6
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/IO/api.cjs +522 -473
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +2 -3
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO/runtime.cjs +9 -10
- package/_cjs/IO/runtime.cjs.map +1 -1
- package/_cjs/IO.cjs +33 -11
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/IOEnv/definition.cjs +1 -2
- package/_cjs/IOEnv/definition.cjs.map +1 -1
- package/_cjs/IOEnv/live.cjs +1 -2
- package/_cjs/IOEnv/live.cjs.map +1 -1
- package/_cjs/IOEnv/services.cjs +1 -2
- package/_cjs/IOEnv/services.cjs.map +1 -1
- package/_cjs/Layer/MemoMap.cjs +1 -2
- package/_cjs/Layer/MemoMap.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +1 -2
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Logger/api.cjs +1 -2
- package/_cjs/Logger/api.cjs.map +1 -1
- package/_cjs/Logger/constructors.cjs +1 -2
- package/_cjs/Logger/constructors.cjs.map +1 -1
- package/_cjs/MVar/api.cjs +1 -2
- package/_cjs/MVar/api.cjs.map +1 -1
- package/_cjs/Push/Bounds.cjs +2 -0
- package/_cjs/Push/Bounds.cjs.map +1 -0
- package/_cjs/Push/FlattenStrategy.cjs +95 -0
- package/_cjs/Push/FlattenStrategy.cjs.map +1 -0
- package/_cjs/Push/IndexedBuffer.cjs +70 -0
- package/_cjs/Push/IndexedBuffer.cjs.map +1 -0
- package/_cjs/Push/MergeStrategy.cjs +45 -0
- package/_cjs/Push/MergeStrategy.cjs.map +1 -0
- package/_cjs/Push/Operator/IOLoopOperator.cjs +225 -0
- package/_cjs/Push/Operator/IOLoopOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/IOOperator.cjs +104 -0
- package/_cjs/Push/Operator/IOOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/LoopOperator.cjs +165 -0
- package/_cjs/Push/Operator/LoopOperator.cjs.map +1 -0
- package/_cjs/Push/Operator/SyncOperator.cjs +78 -0
- package/_cjs/Push/Operator/SyncOperator.cjs.map +1 -0
- package/_cjs/Push/Operator.cjs +2 -0
- package/_cjs/Push/Operator.cjs.map +1 -0
- package/_cjs/Push/Producer/IOProducer.cjs +67 -0
- package/_cjs/Push/Producer/IOProducer.cjs.map +1 -0
- package/_cjs/Push/Producer/SyncProducer.cjs +107 -0
- package/_cjs/Push/Producer/SyncProducer.cjs.map +1 -0
- package/_cjs/Push/Producer.cjs +2 -0
- package/_cjs/Push/Producer.cjs.map +1 -0
- package/_cjs/Push/Sink.cjs +219 -0
- package/_cjs/Push/Sink.cjs.map +1 -0
- package/_cjs/Push/api.cjs +340 -385
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +79 -22
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +32 -28
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/Push.cjs +66 -0
- package/_cjs/Push.cjs.map +1 -1
- package/_cjs/Queue/api/dimapIO.cjs +1 -2
- package/_cjs/Queue/api/dimapIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterInputIO.cjs +1 -2
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterOutputIO.cjs +1 -2
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
- package/_cjs/Queue/api/poll.cjs +1 -2
- package/_cjs/Queue/api/poll.cjs.map +1 -1
- package/_cjs/Queue/api/takeBetween.cjs +1 -2
- package/_cjs/Queue/api/takeBetween.cjs.map +1 -1
- package/_cjs/Queue/api/takeN.cjs +1 -2
- package/_cjs/Queue/api/takeN.cjs.map +1 -1
- package/_cjs/Queue/api/zipWithIO.cjs +1 -2
- package/_cjs/Queue/api/zipWithIO.cjs.map +1 -1
- package/_cjs/Queue/constructors.cjs +1 -2
- package/_cjs/Queue/constructors.cjs.map +1 -1
- package/_cjs/Queue/internal.cjs +1 -2
- package/_cjs/Queue/internal.cjs.map +1 -1
- package/_cjs/Queue/strategy.cjs +1 -2
- package/_cjs/Queue/strategy.cjs.map +1 -1
- package/_cjs/Random/api.cjs +1 -2
- package/_cjs/Random/api.cjs.map +1 -1
- package/_cjs/Random/definition.cjs +2 -2
- package/_cjs/Random/definition.cjs.map +1 -1
- package/_cjs/Random/live.cjs +1 -2
- package/_cjs/Random/live.cjs.map +1 -1
- package/_cjs/Ref/Atomic.cjs +1 -2
- package/_cjs/Ref/Atomic.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +1 -2
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/DerivedAll.cjs +1 -2
- package/_cjs/Ref/DerivedAll.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/api.cjs +2 -3
- package/_cjs/Ref/Synchronized/api.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +2 -3
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +13 -14
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/Ref/api/collect.cjs +1 -2
- package/_cjs/Ref/api/collect.cjs.map +1 -1
- package/_cjs/Ref/api/dimap.cjs +1 -2
- package/_cjs/Ref/api/dimap.cjs.map +1 -1
- package/_cjs/Ref/api/filter.cjs +1 -2
- package/_cjs/Ref/api/filter.cjs.map +1 -1
- package/_cjs/Ref/api/modify.cjs +1 -2
- package/_cjs/Ref/api/modify.cjs.map +1 -1
- package/_cjs/Ref/api.cjs +1 -2
- package/_cjs/Ref/api.cjs.map +1 -1
- package/_cjs/Ref/constructors.cjs +1 -2
- package/_cjs/Ref/constructors.cjs.map +1 -1
- package/_cjs/Ref/definition.cjs.map +1 -1
- package/_cjs/Reloadable/api.cjs +1 -2
- package/_cjs/Reloadable/api.cjs.map +1 -1
- package/_cjs/Reloadable/constructors.cjs +1 -2
- package/_cjs/Reloadable/constructors.cjs.map +1 -1
- package/_cjs/Reloadable/definition.cjs +1 -2
- package/_cjs/Reloadable/definition.cjs.map +1 -1
- package/_cjs/RuntimeFlags/Patch.cjs +1 -2
- package/_cjs/RuntimeFlags/Patch.cjs.map +1 -1
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs +1 -2
- package/_cjs/RuntimeFlags/RuntimeFlags.cjs.map +1 -1
- package/_cjs/STM/api/atomically.cjs +1 -2
- package/_cjs/STM/api/atomically.cjs.map +1 -1
- package/_cjs/STM/api/core-api.cjs +1 -2
- package/_cjs/STM/api/core-api.cjs.map +1 -1
- package/_cjs/STM/api.cjs +1 -2
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs +2 -3
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/STM/driver.cjs +1 -2
- package/_cjs/STM/driver.cjs.map +1 -1
- package/_cjs/STM/internal/CommitState.cjs +1 -2
- package/_cjs/STM/internal/CommitState.cjs.map +1 -1
- package/_cjs/STM/internal/Journal.cjs +1 -2
- package/_cjs/STM/internal/Journal.cjs.map +1 -1
- package/_cjs/Schedule/Decision.cjs +1 -2
- package/_cjs/Schedule/Decision.cjs.map +1 -1
- package/_cjs/Schedule/api/driver.cjs +1 -2
- package/_cjs/Schedule/api/driver.cjs.map +1 -1
- package/_cjs/Schedule/api.cjs +1 -2
- package/_cjs/Schedule/api.cjs.map +1 -1
- package/_cjs/Scope/Finalizer/definition.cjs +1 -2
- package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/api.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/api.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/constructors.cjs.map +1 -1
- package/_cjs/Scope/ReleaseMap/definition.cjs +1 -2
- package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
- package/_cjs/Scope/api.cjs +29 -9
- package/_cjs/Scope/api.cjs.map +1 -1
- package/_cjs/Scope/definition.cjs +1 -2
- package/_cjs/Scope/definition.cjs.map +1 -1
- package/_cjs/ScopedRef/api.cjs +2 -3
- package/_cjs/ScopedRef/api.cjs.map +1 -1
- package/_cjs/Semaphore/Reservation.cjs +24 -0
- package/_cjs/Semaphore/Reservation.cjs.map +1 -0
- package/_cjs/Semaphore/constructors.cjs +25 -0
- package/_cjs/Semaphore/constructors.cjs.map +1 -0
- package/_cjs/Semaphore/definition.cjs +149 -0
- package/_cjs/Semaphore/definition.cjs.map +1 -0
- package/_cjs/Semaphore.cjs +31 -138
- package/_cjs/Semaphore.cjs.map +1 -1
- package/_cjs/Sink/api.cjs +1 -2
- package/_cjs/Sink/api.cjs.map +1 -1
- package/_cjs/Sink/definition.cjs +2 -3
- package/_cjs/Sink/definition.cjs.map +1 -1
- package/_cjs/State/api.cjs +1 -2
- package/_cjs/State/api.cjs.map +1 -1
- package/_cjs/Stream/api/zipAllWith.cjs +1 -2
- package/_cjs/Stream/api/zipAllWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWith.cjs +1 -2
- package/_cjs/Stream/api/zipWith.cjs.map +1 -1
- package/_cjs/Stream/api/zipWithChunks.cjs +1 -2
- package/_cjs/Stream/api/zipWithChunks.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +702 -703
- package/_cjs/Stream/api.cjs.map +1 -1
- package/_cjs/Stream/definition.cjs.map +1 -1
- package/_cjs/Stream/internal/Handoff.cjs +1 -2
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
- package/_cjs/Stream/internal/Pull.cjs +1 -2
- package/_cjs/Stream/internal/Pull.cjs.map +1 -1
- package/_cjs/Stream/internal/Take.cjs +1 -2
- package/_cjs/Stream/internal/Take.cjs.map +1 -1
- package/_cjs/Stream/internal/util.cjs +1 -2
- package/_cjs/Stream/internal/util.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +46 -12
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/Subject/DeferredRef.cjs +53 -0
- package/_cjs/Subject/DeferredRef.cjs.map +1 -0
- package/_cjs/Subject/Hold.cjs +41 -0
- package/_cjs/Subject/Hold.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/Atomic.cjs +130 -0
- package/_cjs/Subject/RefSubject/Atomic.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/Derived.cjs +98 -0
- package/_cjs/Subject/RefSubject/Derived.cjs.map +1 -0
- package/_cjs/Subject/RefSubject/RefSubject.cjs +19 -0
- package/_cjs/Subject/RefSubject/RefSubject.cjs.map +1 -0
- package/_cjs/Subject/api.cjs +1 -2
- package/_cjs/Subject/api.cjs.map +1 -1
- package/_cjs/Subject/definition.cjs +16 -1
- package/_cjs/Subject/definition.cjs.map +1 -1
- package/_cjs/Subject.cjs +22 -0
- package/_cjs/Subject.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +2 -4
- package/_cjs/SubscriptionRef.cjs.map +1 -1
- package/_cjs/Supervisor/api.cjs +1 -2
- package/_cjs/Supervisor/api.cjs.map +1 -1
- package/_cjs/Supervisor/constructors.cjs +1 -2
- package/_cjs/Supervisor/constructors.cjs.map +1 -1
- package/_cjs/Supervisor/definition.cjs +1 -2
- package/_cjs/Supervisor/definition.cjs.map +1 -1
- package/_cjs/SupervisorPatch.cjs +1 -2
- package/_cjs/SupervisorPatch.cjs.map +1 -1
- package/_cjs/TExit/definition.cjs +1 -2
- package/_cjs/TExit/definition.cjs.map +1 -1
- package/_cjs/TFuture/api.cjs +1 -2
- package/_cjs/TFuture/api.cjs.map +1 -1
- package/_cjs/TFuture/constructors.cjs +1 -2
- package/_cjs/TFuture/constructors.cjs.map +1 -1
- package/_cjs/TFuture/definition.cjs +1 -2
- package/_cjs/TFuture/definition.cjs.map +1 -1
- package/_cjs/TReentrantLock/api.cjs +1 -2
- package/_cjs/TReentrantLock/api.cjs.map +1 -1
- package/_cjs/TReentrantLock/definition.cjs +1 -2
- package/_cjs/TReentrantLock/definition.cjs.map +1 -1
- package/_cjs/TRef/api.cjs +1 -2
- package/_cjs/TRef/api.cjs.map +1 -1
- package/_cjs/TRef/constructors.cjs +1 -2
- package/_cjs/TRef/constructors.cjs.map +1 -1
- package/_cjs/TRef/definition.cjs +1 -2
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_cjs/TSemaphore/api.cjs +1 -2
- package/_cjs/TSemaphore/api.cjs.map +1 -1
- package/_cjs/TSemaphore/constructors.cjs +1 -2
- package/_cjs/TSemaphore/constructors.cjs.map +1 -1
- package/_cjs/TSemaphore/definition.cjs +1 -2
- package/_cjs/TSemaphore/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/dropUntilIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/dropWhileIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/filterIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/filterIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/findIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/findIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/mapIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/mapIO.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +1 -2
- package/_cjs/collection/immutable/Conc/takeWhileIO.cjs.map +1 -1
- package/_cjs/data/Exit/foreachIO.cjs +1 -2
- package/_cjs/data/Exit/foreachIO.cjs.map +1 -1
- package/_cjs/internal/HashedPair.cjs +1 -2
- package/_cjs/internal/HashedPair.cjs.map +1 -1
- package/_cjs/internal/Hub.cjs +1 -2
- package/_cjs/internal/Hub.cjs.map +1 -1
- package/_cjs/internal/MutableQueue.cjs +1 -2
- package/_cjs/internal/MutableQueue.cjs.map +1 -1
- package/_cjs/internal/Scheduler.cjs +1 -2
- package/_cjs/internal/Scheduler.cjs.map +1 -1
- package/_cjs/internal/StackTraceBuilder.cjs +1 -2
- package/_cjs/internal/StackTraceBuilder.cjs.map +1 -1
- package/_mjs/Cached/api.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +1 -1
- package/_mjs/Channel/api/runScoped.mjs +2 -2
- package/_mjs/Channel/api/runScoped.mjs.map +1 -1
- package/_mjs/Channel/api/toPull.mjs +1 -1
- package/_mjs/Channel/api/toPull.mjs.map +1 -1
- package/_mjs/Channel/api.mjs +205 -205
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/core-api.mjs +43 -42
- package/_mjs/Channel/core-api.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +3 -3
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Console/definition.mjs +1 -0
- package/_mjs/Console/definition.mjs.map +1 -1
- package/_mjs/CountdownLatch.mjs +2 -1
- package/_mjs/CountdownLatch.mjs.map +1 -1
- package/_mjs/Fiber/FiberMessage.mjs +2 -20
- package/_mjs/Fiber/FiberMessage.mjs.map +1 -1
- package/_mjs/Fiber/FiberRuntime.mjs +877 -633
- package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
- package/_mjs/Fiber/api/collectAll.mjs +1 -1
- package/_mjs/Fiber/api/collectAll.mjs.map +1 -1
- package/_mjs/Fiber/api/interrupt.mjs +1 -1
- package/_mjs/Fiber/api/interrupt.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAll.mjs +1 -1
- package/_mjs/Fiber/api/interruptAll.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptAs.mjs +4 -7
- package/_mjs/Fiber/api/interruptAs.mjs.map +1 -1
- package/_mjs/Fiber/api/interruptFork.mjs +1 -1
- package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
- package/_mjs/Fiber/api/mapIO.mjs +1 -1
- package/_mjs/Fiber/api/mapIO.mjs.map +1 -1
- package/_mjs/Fiber/api/zipWith.mjs +1 -1
- package/_mjs/Fiber/api/zipWith.mjs.map +1 -1
- package/_mjs/Fiber/constructors.mjs +1 -1
- package/_mjs/Fiber/constructors.mjs.map +1 -1
- package/_mjs/Fiber/definition.mjs +5 -2
- package/_mjs/Fiber/definition.mjs.map +1 -1
- package/_mjs/FiberScope/definition.mjs +28 -4
- package/_mjs/FiberScope/definition.mjs.map +1 -1
- package/_mjs/FiberSet.mjs +14 -12
- package/_mjs/FiberSet.mjs.map +1 -1
- package/_mjs/Future/State.mjs +96 -0
- package/_mjs/Future/State.mjs.map +1 -0
- package/_mjs/Future/api.mjs +67 -61
- package/_mjs/Future/api.mjs.map +1 -1
- package/_mjs/Future/constructors.mjs +3 -3
- package/_mjs/Future/constructors.mjs.map +1 -1
- package/_mjs/Future/definition.mjs +0 -12
- package/_mjs/Future/definition.mjs.map +1 -1
- package/_mjs/Future.mjs +1 -0
- package/_mjs/Future.mjs.map +1 -1
- package/_mjs/Hub/api.mjs +55 -55
- package/_mjs/Hub/api.mjs.map +1 -1
- package/_mjs/IO/api/array.mjs +42 -0
- package/_mjs/IO/api/array.mjs.map +1 -0
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
- package/_mjs/IO/api/awaitAllChildren.mjs +10 -0
- package/_mjs/IO/api/awaitAllChildren.mjs.map +1 -0
- package/_mjs/IO/api/cachedInvalidate.mjs +39 -0
- package/_mjs/IO/api/cachedInvalidate.mjs.map +1 -0
- package/_mjs/IO/api/disconnect.mjs +1 -1
- package/_mjs/IO/api/disconnect.mjs.map +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs +35 -28
- package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
- package/_mjs/IO/api/foreachExec.mjs +27 -4
- package/_mjs/IO/api/foreachExec.mjs.map +1 -1
- package/_mjs/IO/api/fork.mjs +1 -1
- package/_mjs/IO/api/fork.mjs.map +1 -1
- package/_mjs/IO/api/forkDaemon.mjs +4 -4
- package/_mjs/IO/api/forkDaemon.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +3 -3
- package/_mjs/IO/api/onTermination.mjs +1 -1
- package/_mjs/IO/api/onTermination.mjs.map +1 -1
- package/_mjs/IO/api/race.mjs +1 -1
- package/_mjs/IO/api/race.mjs.map +1 -1
- package/_mjs/IO/api/timeout.mjs +8 -9
- package/_mjs/IO/api/timeout.mjs.map +1 -1
- package/_mjs/IO/api/transplant.mjs +19 -5
- package/_mjs/IO/api/transplant.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +4 -4
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
- package/_mjs/IO/api.mjs +515 -468
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +1 -1
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO/runtime.mjs +8 -8
- package/_mjs/IO/runtime.mjs.map +1 -1
- package/_mjs/IO.mjs +3 -1
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/IOEnv/definition.mjs.map +1 -1
- package/_mjs/Push/Bounds.mjs +2 -0
- package/_mjs/Push/Bounds.mjs.map +1 -0
- package/_mjs/Push/FlattenStrategy.mjs +86 -0
- package/_mjs/Push/FlattenStrategy.mjs.map +1 -0
- package/_mjs/Push/IndexedBuffer.mjs +61 -0
- package/_mjs/Push/IndexedBuffer.mjs.map +1 -0
- package/_mjs/Push/MergeStrategy.mjs +34 -0
- package/_mjs/Push/MergeStrategy.mjs.map +1 -0
- package/_mjs/Push/Operator/IOLoopOperator.mjs +208 -0
- package/_mjs/Push/Operator/IOLoopOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/IOOperator.mjs +91 -0
- package/_mjs/Push/Operator/IOOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/LoopOperator.mjs +151 -0
- package/_mjs/Push/Operator/LoopOperator.mjs.map +1 -0
- package/_mjs/Push/Operator/SyncOperator.mjs +67 -0
- package/_mjs/Push/Operator/SyncOperator.mjs.map +1 -0
- package/_mjs/Push/Operator.mjs +2 -0
- package/_mjs/Push/Operator.mjs.map +1 -0
- package/_mjs/Push/Producer/IOProducer.mjs +55 -0
- package/_mjs/Push/Producer/IOProducer.mjs.map +1 -0
- package/_mjs/Push/Producer/SyncProducer.mjs +90 -0
- package/_mjs/Push/Producer/SyncProducer.mjs.map +1 -0
- package/_mjs/Push/Producer.mjs +2 -0
- package/_mjs/Push/Producer.mjs.map +1 -0
- package/_mjs/Push/Sink.mjs +206 -0
- package/_mjs/Push/Sink.mjs.map +1 -0
- package/_mjs/Push/api.mjs +311 -344
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +73 -18
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +30 -26
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/Push.mjs +7 -1
- package/_mjs/Push.mjs.map +1 -1
- package/_mjs/Random/definition.mjs +1 -0
- package/_mjs/Random/definition.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/api.mjs +1 -1
- package/_mjs/Ref/Synchronized/api.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/constructors.mjs +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +12 -12
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/Ref/definition.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +1 -1
- package/_mjs/Scope/api.mjs +22 -4
- package/_mjs/Scope/api.mjs.map +1 -1
- package/_mjs/ScopedRef/api.mjs +1 -1
- package/_mjs/ScopedRef/api.mjs.map +1 -1
- package/_mjs/Semaphore/Reservation.mjs +16 -0
- package/_mjs/Semaphore/Reservation.mjs.map +1 -0
- package/_mjs/Semaphore/constructors.mjs +17 -0
- package/_mjs/Semaphore/constructors.mjs.map +1 -0
- package/_mjs/Semaphore/definition.mjs +141 -0
- package/_mjs/Semaphore/definition.mjs.map +1 -0
- package/_mjs/Semaphore.mjs +4 -133
- package/_mjs/Semaphore.mjs.map +1 -1
- package/_mjs/Sink/definition.mjs +2 -3
- package/_mjs/Sink/definition.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +701 -701
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/Stream/definition.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +46 -10
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_mjs/Subject/DeferredRef.mjs +45 -0
- package/_mjs/Subject/DeferredRef.mjs.map +1 -0
- package/_mjs/Subject/Hold.mjs +33 -0
- package/_mjs/Subject/Hold.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/Atomic.mjs +122 -0
- package/_mjs/Subject/RefSubject/Atomic.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/Derived.mjs +90 -0
- package/_mjs/Subject/RefSubject/Derived.mjs.map +1 -0
- package/_mjs/Subject/RefSubject/RefSubject.mjs +12 -0
- package/_mjs/Subject/RefSubject/RefSubject.mjs.map +1 -0
- package/_mjs/Subject/definition.mjs +14 -0
- package/_mjs/Subject/definition.mjs.map +1 -1
- package/_mjs/Subject.mjs +2 -0
- package/_mjs/Subject.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +1 -2
- package/_mjs/SubscriptionRef.mjs.map +1 -1
- package/_src/Cached/api.ts +3 -3
- package/_src/Channel/api/toPull.ts +1 -1
- package/_src/Channel/api.ts +273 -272
- package/_src/Channel/core-api.ts +57 -55
- package/_src/Channel/internal/ChannelExecutor.ts +3 -3
- package/_src/Console/definition.ts +1 -0
- package/_src/CountdownLatch.ts +2 -0
- package/_src/Fiber/FiberMessage.ts +3 -28
- package/_src/Fiber/FiberRuntime.ts +988 -616
- package/_src/Fiber/api/interruptAs.ts +4 -3
- package/_src/Fiber/constructors.ts +1 -1
- package/_src/Fiber/definition.ts +4 -0
- package/_src/FiberScope/definition.ts +40 -2
- package/_src/FiberSet.ts +6 -2
- package/_src/Future/State.ts +128 -0
- package/_src/Future/api.ts +62 -51
- package/_src/Future/constructors.ts +4 -2
- package/_src/Future/definition.ts +2 -17
- package/_src/Future.ts +4 -3
- package/_src/Hub/api.ts +61 -61
- package/_src/IO/api/addFinalizerExit.ts +4 -4
- package/_src/IO/api/array.ts +49 -0
- package/_src/IO/api/asyncInterrupt.ts +1 -1
- package/_src/IO/api/awaitAllChildren.ts +6 -0
- package/_src/IO/api/cachedInvalidate.ts +42 -0
- package/_src/IO/api/foreachConcurrent.ts +39 -23
- package/_src/IO/api/foreachExec.ts +47 -0
- package/_src/IO/api/fork.ts +1 -1
- package/_src/IO/api/forkDaemon.ts +2 -2
- package/_src/IO/api/memoize.ts +3 -3
- package/_src/IO/api/onTermination.ts +2 -2
- package/_src/IO/api/transplant.ts +26 -3
- package/_src/IO/api/zipConcurrent.ts +2 -2
- package/_src/IO/api.ts +547 -525
- package/_src/IO/definition.ts +4 -28
- package/_src/IO/runtime.ts +0 -1
- package/_src/IO.ts +65 -63
- package/_src/IOEnv/definition.ts +1 -4
- package/_src/Push/Bounds.ts +4 -0
- package/_src/Push/FlattenStrategy.ts +137 -0
- package/_src/Push/IndexedBuffer.ts +79 -0
- package/_src/Push/MergeStrategy.ts +59 -0
- package/_src/Push/Operator/IOLoopOperator.ts +413 -0
- package/_src/Push/Operator/IOOperator.ts +173 -0
- package/_src/Push/Operator/LoopOperator.ts +242 -0
- package/_src/Push/Operator/SyncOperator.ts +107 -0
- package/_src/Push/Operator.ts +7 -0
- package/_src/Push/Producer/IOProducer.ts +83 -0
- package/_src/Push/Producer/SyncProducer.ts +105 -0
- package/_src/Push/Producer.ts +0 -0
- package/_src/Push/Sink.ts +302 -0
- package/_src/Push/api.ts +387 -513
- package/_src/Push/definition.ts +216 -23
- package/_src/Push/internal.ts +11 -0
- package/_src/Push.ts +7 -1
- package/_src/Random/definition.ts +1 -0
- package/_src/Ref/Synchronized/api.ts +2 -2
- package/_src/Ref/Synchronized/definition.ts +82 -38
- package/_src/Ref/definition.ts +26 -0
- package/_src/Scope/api.ts +22 -0
- package/_src/Semaphore/Reservation.ts +15 -0
- package/_src/Semaphore/constructors.ts +14 -0
- package/_src/Semaphore/definition.ts +180 -0
- package/_src/Semaphore.ts +5 -159
- package/_src/Sink/definition.ts +4 -5
- package/_src/Stream/api.ts +679 -679
- package/_src/Stream/definition.ts +0 -1
- package/_src/Subject/Atomic.ts +68 -11
- package/_src/Subject/DeferredRef.ts +44 -0
- package/_src/Subject/Hold.ts +48 -0
- package/_src/Subject/RefSubject/Atomic.ts +193 -0
- package/_src/Subject/RefSubject/Derived.ts +179 -0
- package/_src/Subject/RefSubject/RefSubject.ts +90 -0
- package/_src/Subject/definition.ts +21 -3
- package/_src/Subject.ts +5 -3
- package/_src/SubscriptionRef.ts +1 -1
- package/_src/index.ts +49 -50
- package/index.d.ts +0 -1
- package/package.json +4 -4
- package/IO/api/sequenceT.d.ts +0 -26
- package/RefSubject/Atomic.d.ts +0 -34
- package/RefSubject/Synchronized/api.d.ts +0 -9
- package/RefSubject/Synchronized/definition.d.ts +0 -39
- package/RefSubject/api.d.ts +0 -120
- package/RefSubject/definition.d.ts +0 -52
- package/RefSubject.d.ts +0 -3
- package/_cjs/IO/api/sequenceT.cjs +0 -18
- package/_cjs/IO/api/sequenceT.cjs.map +0 -1
- package/_cjs/RefSubject/Atomic.cjs +0 -108
- package/_cjs/RefSubject/Atomic.cjs.map +0 -1
- package/_cjs/RefSubject/Synchronized/api.cjs +0 -23
- package/_cjs/RefSubject/Synchronized/api.cjs.map +0 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +0 -56
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +0 -1
- package/_cjs/RefSubject/api.cjs +0 -252
- package/_cjs/RefSubject/api.cjs.map +0 -1
- package/_cjs/RefSubject/definition.cjs +0 -26
- package/_cjs/RefSubject/definition.cjs.map +0 -1
- package/_cjs/RefSubject.cjs +0 -39
- package/_cjs/RefSubject.cjs.map +0 -1
- package/_mjs/IO/api/sequenceT.mjs +0 -10
- package/_mjs/IO/api/sequenceT.mjs.map +0 -1
- package/_mjs/RefSubject/Atomic.mjs +0 -99
- package/_mjs/RefSubject/Atomic.mjs.map +0 -1
- package/_mjs/RefSubject/Synchronized/api.mjs +0 -15
- package/_mjs/RefSubject/Synchronized/api.mjs.map +0 -1
- package/_mjs/RefSubject/Synchronized/definition.mjs +0 -47
- package/_mjs/RefSubject/Synchronized/definition.mjs.map +0 -1
- package/_mjs/RefSubject/api.mjs +0 -229
- package/_mjs/RefSubject/api.mjs.map +0 -1
- package/_mjs/RefSubject/definition.mjs +0 -19
- package/_mjs/RefSubject/definition.mjs.map +0 -1
- package/_mjs/RefSubject.mjs +0 -5
- package/_mjs/RefSubject.mjs.map +0 -1
- package/_src/IO/api/sequenceT.ts +0 -16
- package/_src/RefSubject/Atomic.ts +0 -129
- package/_src/RefSubject/Synchronized/api.ts +0 -14
- package/_src/RefSubject/Synchronized/definition.ts +0 -76
- package/_src/RefSubject/api.ts +0 -253
- package/_src/RefSubject/definition.ts +0 -70
- package/_src/RefSubject.ts +0 -5
|
@@ -1,105 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint perfectionist/sort-classes: "error" */
|
|
2
|
+
|
|
3
|
+
import type { Running } from "../FiberStatus.js";
|
|
4
|
+
import type { OnSuccess, OnSuccessAndFailure, UIO, UpdateRuntimeFlags } from "../IO/definition.js";
|
|
3
5
|
import type { WhileLoop } from "../IO/definition.js";
|
|
4
6
|
import type { RuntimeFlags } from "../RuntimeFlags.js";
|
|
5
7
|
|
|
8
|
+
import { IterableWeakSet } from "@fncts/base/collection/weak/IterableWeakSet";
|
|
6
9
|
import { EitherTag } from "@fncts/base/data/Either";
|
|
7
10
|
import { isIOError } from "@fncts/base/data/exceptions";
|
|
8
11
|
import { ExitTag } from "@fncts/base/data/Exit";
|
|
9
12
|
import { MaybeTag } from "@fncts/base/data/Maybe";
|
|
10
13
|
import { Trace } from "@fncts/base/data/Trace";
|
|
14
|
+
import { assert } from "@fncts/base/util/assert";
|
|
11
15
|
import { FiberTypeId, FiberVariance } from "@fncts/io/Fiber/definition";
|
|
12
16
|
import { StackTraceBuilder } from "@fncts/io/internal/StackTraceBuilder";
|
|
13
17
|
|
|
14
|
-
import {
|
|
15
|
-
import { Running } from "../FiberStatus.js";
|
|
16
|
-
import { FiberStatusTag } from "../FiberStatus.js";
|
|
18
|
+
import { FiberStatus } from "../FiberStatus.js";
|
|
17
19
|
import { LinkedQueue } from "../internal/MutableQueue.js";
|
|
18
|
-
import { IOPrimitive
|
|
20
|
+
import { IOPrimitive } from "../IO/definition.js";
|
|
19
21
|
import { IOTag } from "../IO/definition.js";
|
|
20
22
|
import { RuntimeFlag } from "../RuntimeFlag.js";
|
|
21
23
|
import { FiberMessage, FiberMessageTag } from "./FiberMessage.js";
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly trace?: string,
|
|
28
|
-
) {}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class UpdateTrace {
|
|
32
|
-
readonly _ioOpCode = IOTag.UpdateTrace;
|
|
33
|
-
constructor(readonly trace?: string) {}
|
|
34
|
-
}
|
|
25
|
+
const MAX_FORKS_BEFORE_YIELD = 128;
|
|
26
|
+
const MAX_DEPTH_BEFORE_TRAMPOLINE = 300;
|
|
27
|
+
const INITIAL_STACK_SIZE = 16;
|
|
28
|
+
const STACK_IDX_GC_THRESHOLD = 128;
|
|
35
29
|
|
|
36
|
-
export type Continuation = OnSuccess | OnSuccessAndFailure |
|
|
30
|
+
export type Continuation = OnSuccess | OnSuccessAndFailure | WhileLoop | UpdateRuntimeFlags;
|
|
37
31
|
|
|
38
32
|
/**
|
|
39
33
|
* @tsplus type fncts.io.Fiber
|
|
40
34
|
*/
|
|
41
35
|
export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
36
|
+
readonly _tag = "RuntimeFiber";
|
|
37
|
+
|
|
42
38
|
readonly [FiberTypeId]: FiberTypeId = FiberTypeId;
|
|
39
|
+
|
|
43
40
|
declare [FiberVariance]: {
|
|
44
41
|
readonly _E: (_: never) => E;
|
|
45
42
|
readonly _A: (_: never) => A;
|
|
46
43
|
};
|
|
47
|
-
readonly _tag = "RuntimeFiber";
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
readonly fiberId: FiberId.Runtime,
|
|
51
|
-
fiberRefs0: FiberRefs,
|
|
52
|
-
readonly runtimeFlags0: RuntimeFlags,
|
|
53
|
-
) {
|
|
54
|
-
this._fiberRefs = fiberRefs0;
|
|
55
|
-
this._runtimeFlags = runtimeFlags0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private _fiberRefs: FiberRefs;
|
|
59
|
-
private _runtimeFlags: RuntimeFlags;
|
|
60
|
-
private queue = new LinkedQueue<FiberMessage>();
|
|
61
|
-
private _children = null! as Set<FiberRuntime<any, any>>;
|
|
62
|
-
private observers = List<(_: Exit<E, A>) => void>();
|
|
63
|
-
private running = false;
|
|
64
|
-
private stack = new Stack<Continuation>();
|
|
65
|
-
private asyncInterruptor = null! as (_: IO<any, any, any>) => any;
|
|
66
|
-
private asyncTrace = null! as string;
|
|
67
|
-
private asyncBlockinOn = null! as FiberId;
|
|
68
|
-
private _exitValue = null! as Exit<E, A>;
|
|
69
|
-
|
|
70
|
-
get id(): FiberId.Runtime {
|
|
71
|
-
return this.fiberId;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
ask<A>(f: (fiberRuntime: FiberRuntime<any, any>, status: FiberStatus) => A): UIO<A> {
|
|
75
|
-
return IO.defer(() => {
|
|
76
|
-
const future = Future.unsafeMake<never, A>(this.fiberId);
|
|
77
|
-
|
|
78
|
-
this.tell(FiberMessage.Stateful((fiber, status) => future.unsafeDone(IO.succeed(f(fiber, status)))));
|
|
79
44
|
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
}
|
|
45
|
+
location = this.fiberId.location;
|
|
83
46
|
|
|
84
47
|
get await(): UIO<Exit<E, A>> {
|
|
85
|
-
return IO.
|
|
86
|
-
(cb) =>
|
|
87
|
-
this.tell(
|
|
88
|
-
FiberMessage.Stateful((fiber, _) => {
|
|
89
|
-
if (fiber._exitValue !== null) cb(IO.succeedNow(fiber.exitValue()));
|
|
90
|
-
else fiber.addObserver((exit) => cb(IO.succeedNow(exit)));
|
|
91
|
-
}),
|
|
92
|
-
),
|
|
93
|
-
this.id,
|
|
94
|
-
);
|
|
48
|
+
return IO.defer(this.awaitUnsafe());
|
|
95
49
|
}
|
|
96
50
|
|
|
97
51
|
get children(): UIO<Conc<FiberRuntime<any, any>>> {
|
|
98
|
-
return this.
|
|
52
|
+
return IO(this.childrenChunk(this._children));
|
|
99
53
|
}
|
|
100
54
|
|
|
101
55
|
get fiberRefs(): UIO<FiberRefs> {
|
|
102
|
-
return this.
|
|
56
|
+
return IO(this._fiberRefs);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get id(): FiberId.Runtime {
|
|
60
|
+
return this.fiberId;
|
|
103
61
|
}
|
|
104
62
|
|
|
105
63
|
get inheritAll(): UIO<void> {
|
|
@@ -124,749 +82,1141 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
|
124
82
|
});
|
|
125
83
|
}
|
|
126
84
|
|
|
127
|
-
get
|
|
128
|
-
return this.
|
|
129
|
-
if (status._tag === FiberStatusTag.Done) return state._runtimeFlags;
|
|
130
|
-
else return status.runtimeFlags;
|
|
131
|
-
});
|
|
85
|
+
get poll(): UIO<Maybe<Exit<E, A>>> {
|
|
86
|
+
return IO.succeed(Maybe.fromNullable(this.exitValue()));
|
|
132
87
|
}
|
|
133
88
|
|
|
134
|
-
|
|
135
|
-
return IO.
|
|
136
|
-
const cause = Cause.interrupt(fiberId);
|
|
137
|
-
this.tell(FiberMessage.InterruptSignal(cause));
|
|
138
|
-
});
|
|
89
|
+
get runtimeFlags(): UIO<RuntimeFlags> {
|
|
90
|
+
return IO(this._runtimeFlags);
|
|
139
91
|
}
|
|
140
92
|
|
|
141
|
-
|
|
142
|
-
return
|
|
93
|
+
get scope() {
|
|
94
|
+
return FiberScope.unsafeMake(this);
|
|
143
95
|
}
|
|
144
96
|
|
|
145
|
-
get
|
|
146
|
-
return IO
|
|
97
|
+
get status(): UIO<FiberStatus> {
|
|
98
|
+
return IO(this.getStatus());
|
|
147
99
|
}
|
|
148
100
|
|
|
149
|
-
|
|
150
|
-
this.
|
|
101
|
+
get trace(): UIO<Trace> {
|
|
102
|
+
return IO(this.generateStackTrace());
|
|
151
103
|
}
|
|
152
104
|
|
|
153
|
-
private
|
|
154
|
-
|
|
105
|
+
private _asyncContWith: ((_: IO<any, any, any>) => any) | null = null;
|
|
106
|
+
private _blockingOn: FiberId | null = null;
|
|
107
|
+
private _children = null! as IterableWeakSet<FiberRuntime<any, any>>;
|
|
108
|
+
private _exitValue: Exit<E, A> | null = null;
|
|
109
|
+
private _fiberRefs: FiberRefs;
|
|
110
|
+
private _forksSinceYield = 0;
|
|
111
|
+
private _lastTrace: string | undefined;
|
|
112
|
+
private _runtimeFlags: RuntimeFlags;
|
|
113
|
+
private _stack = null! as Array<Continuation>;
|
|
114
|
+
private _stackSize = 0;
|
|
115
|
+
private inbox = new LinkedQueue<FiberMessage>();
|
|
116
|
+
private observers = List<(_: Exit<E, A>) => void>();
|
|
117
|
+
private running = false;
|
|
155
118
|
|
|
156
|
-
|
|
119
|
+
constructor(
|
|
120
|
+
readonly fiberId: FiberId.Runtime,
|
|
121
|
+
fiberRefs0: FiberRefs,
|
|
122
|
+
readonly runtimeFlags0: RuntimeFlags,
|
|
123
|
+
) {
|
|
124
|
+
this._fiberRefs = fiberRefs0;
|
|
125
|
+
this._runtimeFlags = runtimeFlags0;
|
|
126
|
+
}
|
|
157
127
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
128
|
+
addChild(child: FiberRuntime<any, any>): void {
|
|
129
|
+
this.getChildren().add(child);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
addChildren(children: Iterable<FiberRuntime<any, any>>): void {
|
|
133
|
+
if (this.isAlive()) {
|
|
134
|
+
const childs = this.getChildren();
|
|
135
|
+
if (this.shouldInterrupt()) {
|
|
136
|
+
const cause = this.getInterruptedCause();
|
|
137
|
+
for (const child of children) {
|
|
138
|
+
if (child.isAlive()) {
|
|
139
|
+
childs.add(child);
|
|
140
|
+
child.tellInterrupt(cause);
|
|
141
|
+
}
|
|
168
142
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
143
|
+
} else {
|
|
144
|
+
for (const child of children) {
|
|
145
|
+
if (child.isAlive()) {
|
|
146
|
+
childs.add(child);
|
|
147
|
+
}
|
|
173
148
|
}
|
|
174
149
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
recurse = false;
|
|
181
|
-
} else {
|
|
182
|
-
recurse = true;
|
|
150
|
+
} else {
|
|
151
|
+
const cause = this.getInterruptedCause();
|
|
152
|
+
for (const child of children) {
|
|
153
|
+
if (child.isAlive()) {
|
|
154
|
+
child.tellInterrupt(cause);
|
|
183
155
|
}
|
|
184
|
-
} else {
|
|
185
|
-
recurse = false;
|
|
186
156
|
}
|
|
187
157
|
}
|
|
188
158
|
}
|
|
189
159
|
|
|
190
|
-
|
|
191
|
-
|
|
160
|
+
addObserver(observer: (exit: Exit<E, A>) => void): void {
|
|
161
|
+
if (this._exitValue !== null) observer(this._exitValue);
|
|
162
|
+
else this.observers = Cons(observer, this.observers);
|
|
163
|
+
}
|
|
192
164
|
|
|
193
|
-
|
|
165
|
+
deleteFiberRef(ref: FiberRef<any>): void {
|
|
166
|
+
this._fiberRefs = this._fiberRefs.delete(ref);
|
|
194
167
|
}
|
|
195
168
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
cur0: IO<any, any, any>,
|
|
200
|
-
): IO<any, any, any> {
|
|
201
|
-
let cur = cur0;
|
|
169
|
+
exitValue(): Exit<E, A> | null {
|
|
170
|
+
return this._exitValue;
|
|
171
|
+
}
|
|
202
172
|
|
|
203
|
-
|
|
204
|
-
|
|
173
|
+
generateStackTrace() {
|
|
174
|
+
const builder = new StackTraceBuilder();
|
|
205
175
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
cur = IO.stackTrace(undefined).flatMap((stackTrace) => {
|
|
215
|
-
message.onTrace(stackTrace);
|
|
216
|
-
return oldCur;
|
|
217
|
-
}, undefined);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case FiberMessageTag.Stateful: {
|
|
221
|
-
message.onFiber(this, new Running(runtimeFlags, lastTrace));
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case FiberMessageTag.Resume: {
|
|
225
|
-
throw new IllegalStateError("It is illegal to have multiple concurrent run loops in a single fiber");
|
|
226
|
-
}
|
|
227
|
-
case FiberMessageTag.YieldNow: {
|
|
228
|
-
const oldCur = cur;
|
|
229
|
-
cur = IO.yieldNow.flatMap(() => oldCur, undefined);
|
|
230
|
-
break;
|
|
176
|
+
const stack = this._stack;
|
|
177
|
+
const size = this._stackSize;
|
|
178
|
+
|
|
179
|
+
if (stack !== null) {
|
|
180
|
+
for (let i = stack.length < size ? stack.length : size; i >= 0; i--) {
|
|
181
|
+
const k = stack[i];
|
|
182
|
+
if (k != null) {
|
|
183
|
+
builder.append(TraceElement.parse(k.trace));
|
|
231
184
|
}
|
|
232
185
|
}
|
|
186
|
+
|
|
187
|
+
builder.append(TraceElement.parse(this.id.location));
|
|
233
188
|
}
|
|
189
|
+
return new Trace(this.fiberId, builder.result());
|
|
190
|
+
}
|
|
234
191
|
|
|
235
|
-
|
|
192
|
+
getChildren(): Set<FiberRuntime<any, any>> {
|
|
193
|
+
let children = this._children;
|
|
194
|
+
if (children === null) {
|
|
195
|
+
children = new IterableWeakSet();
|
|
196
|
+
this._children = children;
|
|
197
|
+
}
|
|
198
|
+
return children;
|
|
236
199
|
}
|
|
237
200
|
|
|
238
|
-
|
|
239
|
-
|
|
201
|
+
getFiberRef<A>(fiberRef: FiberRef<A>): A {
|
|
202
|
+
if (this._fiberRefs.unFiberRefs.has(fiberRef)) {
|
|
203
|
+
return this._fiberRefs.unFiberRefs.unsafeGet(fiberRef)!.head[1] as A;
|
|
204
|
+
}
|
|
205
|
+
return fiberRef.initial;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getFiberRefs(): FiberRefs {
|
|
209
|
+
return this._fiberRefs;
|
|
210
|
+
}
|
|
240
211
|
|
|
241
|
-
|
|
212
|
+
getInterruptedCause(): Cause<never> {
|
|
213
|
+
return this.getFiberRef(FiberRef.interruptedCause);
|
|
214
|
+
}
|
|
242
215
|
|
|
243
|
-
|
|
244
|
-
|
|
216
|
+
getSupervisor(): Supervisor<any> {
|
|
217
|
+
return this.getFiberRef(FiberRef.currentSupervisor);
|
|
218
|
+
}
|
|
245
219
|
|
|
246
|
-
|
|
247
|
-
|
|
220
|
+
interruptAs(fiberId: FiberId, __tsplusTrace?: string): UIO<Exit<E, A>> {
|
|
221
|
+
return IO.defer(() => {
|
|
222
|
+
const exit = this._exitValue;
|
|
223
|
+
if (exit !== null) {
|
|
224
|
+
return Exit.succeed(exit);
|
|
248
225
|
} else {
|
|
249
|
-
|
|
226
|
+
const cause = Cause.interrupt(fiberId, Trace(this.fiberId, Conc.single(TraceElement.parse(__tsplusTrace))));
|
|
227
|
+
this.tell(FiberMessage.InterruptSignal(cause));
|
|
228
|
+
return this.awaitUnsafe(__tsplusTrace);
|
|
250
229
|
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
251
232
|
|
|
252
|
-
|
|
233
|
+
interruptAsFork(fiberId: FiberId, __tsplusTrace?: string): UIO<void> {
|
|
234
|
+
return IO.succeed(() => {
|
|
235
|
+
const cause = Cause.interrupt(fiberId);
|
|
236
|
+
this.tell(FiberMessage.InterruptSignal(cause));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
253
239
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this._runtimeFlags = this._runtimeFlags.enable(RuntimeFlag.WindDown);
|
|
258
|
-
const interruption = this.interruptAllChildren();
|
|
259
|
-
|
|
260
|
-
if (interruption === null) {
|
|
261
|
-
if (this.queue.isEmpty) {
|
|
262
|
-
finalExit = exit;
|
|
263
|
-
this.setExitValue(exit);
|
|
264
|
-
} else {
|
|
265
|
-
this.tell(FiberMessage.Resume(IO.fromExitNow(exit)));
|
|
266
|
-
}
|
|
240
|
+
isAlive(): boolean {
|
|
241
|
+
return this.exitValue === null;
|
|
242
|
+
}
|
|
267
243
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
244
|
+
isDone(): boolean {
|
|
245
|
+
return this.exitValue !== null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
isFatal(t: unknown): boolean {
|
|
249
|
+
return this.getFiberRef(FiberRef.currentIsFatal).apply(t);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
isInterrupted(): boolean {
|
|
253
|
+
return !this.getFiberRef(FiberRef.interruptedCause).isEmpty;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
log(message: () => string, cause: Cause<any>, overrideLogLevel: Maybe<LogLevel>, trace?: string): void {
|
|
257
|
+
const logLevel = overrideLogLevel.getOrElse(this.getFiberRef(FiberRef.currentLogLevel));
|
|
258
|
+
const spans = this.getFiberRef(FiberRef.currentLogSpan);
|
|
259
|
+
const annotations = this.getFiberRef(FiberRef.currentLogAnnotations);
|
|
260
|
+
const contextMap = this.getFiberRefs();
|
|
261
|
+
Logger.defaultString
|
|
262
|
+
.map((s) => console.log(s))
|
|
263
|
+
.filterLogLevel((level) => level >= LogLevel.Info)
|
|
264
|
+
.log(
|
|
265
|
+
TraceElement.parse(trace),
|
|
266
|
+
this.fiberId,
|
|
267
|
+
logLevel,
|
|
268
|
+
message,
|
|
269
|
+
cause,
|
|
270
|
+
contextMap.unFiberRefs,
|
|
271
|
+
spans,
|
|
272
|
+
annotations,
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
removeChild(child: FiberRuntime<any, any>) {
|
|
277
|
+
if (this._children !== null) {
|
|
278
|
+
this._children.delete(child);
|
|
294
279
|
}
|
|
295
280
|
}
|
|
296
281
|
|
|
297
|
-
|
|
298
|
-
|
|
282
|
+
removeObserver(observer: (exit: Exit<E, A>) => void): void {
|
|
283
|
+
this.observers = this.observers.filter((f) => f !== observer);
|
|
284
|
+
}
|
|
299
285
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
286
|
+
resume<R>(effect: IO<R, E, A>) {
|
|
287
|
+
this.tell(FiberMessage.Resume(effect));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
runLoop(
|
|
291
|
+
effect: IO.Concrete,
|
|
292
|
+
minStackIndex: number,
|
|
293
|
+
startStackIndex: number,
|
|
294
|
+
currentDepth: number,
|
|
295
|
+
currentOps: number,
|
|
296
|
+
): Exit<any, any> | null {
|
|
297
|
+
assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
|
298
|
+
|
|
299
|
+
let op: IO.Concrete | null = effect;
|
|
300
|
+
let ops = currentOps;
|
|
301
|
+
let stackIndex = startStackIndex;
|
|
302
|
+
|
|
303
|
+
if (currentDepth >= MAX_DEPTH_BEFORE_TRAMPOLINE) {
|
|
304
|
+
this.inbox.enqueue(FiberMessage.Resume(effect));
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
303
307
|
|
|
304
308
|
while (true) {
|
|
305
309
|
if ((this._runtimeFlags & RuntimeFlag.OpSupervision) !== 0) {
|
|
306
|
-
this.getSupervisor().unsafeOnEffect(this,
|
|
310
|
+
this.getSupervisor().unsafeOnEffect(this, op!);
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
if (nextTrace !== undefined) lastTrace = nextTrace;
|
|
311
|
-
|
|
312
|
-
cur = IO.concrete(this.drainQueueWhileRunning(this._runtimeFlags, lastTrace, cur));
|
|
313
|
+
op = IO.concrete(this.drainQueueWhileRunning(op!));
|
|
313
314
|
|
|
314
315
|
ops += 1;
|
|
315
316
|
|
|
316
317
|
if (ops > this.getFiberRef(FiberRef.currentMaxFiberOps)) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
this.updateLastTrace(op.trace);
|
|
319
|
+
this.inbox.enqueue(FiberMessage.Resume(op));
|
|
320
|
+
|
|
321
|
+
return null;
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
cur = IO.concrete(IO.unit);
|
|
344
|
-
}
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
case IOTag.RevertFlags: {
|
|
348
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
|
349
|
-
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
|
350
|
-
cur = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
|
351
|
-
} else {
|
|
352
|
-
cur = IO.concrete(IO.succeedNow(value));
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
case IOTag.UpdateTrace: {
|
|
357
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
|
358
|
-
cur = IO.concrete(IO.unit);
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
} else {
|
|
363
|
-
return Exit.succeed(value);
|
|
323
|
+
|
|
324
|
+
switch (op._ioOpCode) {
|
|
325
|
+
case IOTag.SucceedNow: {
|
|
326
|
+
const value = op.i0;
|
|
327
|
+
|
|
328
|
+
op = null;
|
|
329
|
+
|
|
330
|
+
while (op === null && stackIndex > minStackIndex) {
|
|
331
|
+
stackIndex -= 1;
|
|
332
|
+
const continuation = this._stack[stackIndex];
|
|
333
|
+
this.popStackFrame(stackIndex);
|
|
334
|
+
switch (continuation._ioOpCode) {
|
|
335
|
+
case IOTag.OnSuccess:
|
|
336
|
+
op = continuation.i1(value);
|
|
337
|
+
break;
|
|
338
|
+
case IOTag.OnSuccessAndFailure:
|
|
339
|
+
op = continuation.i2(value);
|
|
340
|
+
break;
|
|
341
|
+
case IOTag.UpdateRuntimeFlags:
|
|
342
|
+
op = this.patchRuntimeFlags(continuation.i0, null, null);
|
|
343
|
+
break;
|
|
364
344
|
}
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
case IOTag.OnSuccessAndFailure:
|
|
368
|
-
case IOTag.OnFailure:
|
|
369
|
-
case IOTag.OnSuccess: {
|
|
370
|
-
this.stack.push(cur);
|
|
371
|
-
cur = IO.concrete(cur.i0);
|
|
372
|
-
break;
|
|
373
345
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
this.initiateAsync(this._runtimeFlags, cur.i0);
|
|
378
|
-
throw cur;
|
|
346
|
+
|
|
347
|
+
if (op === null) {
|
|
348
|
+
return Exit.succeed(value);
|
|
379
349
|
}
|
|
380
|
-
case IOTag.UpdateRuntimeFlagsWithin: {
|
|
381
|
-
const updateFlags = cur.i0;
|
|
382
|
-
const oldRuntimeFlags = this._runtimeFlags;
|
|
383
|
-
const newRuntimeFlags = updateFlags.patch(oldRuntimeFlags);
|
|
384
350
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case IOTag.Sync: {
|
|
354
|
+
this.updateLastTrace(op.trace);
|
|
355
|
+
const value = op.i0();
|
|
356
|
+
|
|
357
|
+
op = null;
|
|
358
|
+
|
|
359
|
+
while (op === null && stackIndex > minStackIndex) {
|
|
360
|
+
stackIndex -= 1;
|
|
361
|
+
const continuation = this._stack[stackIndex];
|
|
362
|
+
this.popStackFrame(stackIndex);
|
|
363
|
+
|
|
364
|
+
switch (continuation._ioOpCode) {
|
|
365
|
+
case IOTag.OnSuccess:
|
|
366
|
+
op = continuation.i1(value);
|
|
367
|
+
break;
|
|
368
|
+
case IOTag.OnSuccessAndFailure:
|
|
369
|
+
op = continuation.i2(value);
|
|
370
|
+
break;
|
|
371
|
+
case IOTag.UpdateRuntimeFlags:
|
|
372
|
+
op = this.patchRuntimeFlags(continuation.i0, null, null);
|
|
373
|
+
break;
|
|
396
374
|
}
|
|
397
|
-
break;
|
|
398
375
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
376
|
+
|
|
377
|
+
if (op === null) {
|
|
378
|
+
return Exit.succeed(value);
|
|
402
379
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
case IOTag.OnSuccess: {
|
|
383
|
+
this.updateLastTrace(op.trace);
|
|
384
|
+
|
|
385
|
+
const first = op.i0;
|
|
386
|
+
|
|
387
|
+
if (first === IO.unit) {
|
|
388
|
+
op = op.i1(undefined);
|
|
389
|
+
} else {
|
|
390
|
+
stackIndex = this.pushStackFrame(op, stackIndex);
|
|
391
|
+
|
|
392
|
+
const result = this.runLoop(first, stackIndex, stackIndex, currentDepth + 1, ops);
|
|
393
|
+
ops += 1;
|
|
394
|
+
|
|
395
|
+
if (result === null) {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
stackIndex -= 1;
|
|
400
|
+
this.popStackFrame(stackIndex);
|
|
401
|
+
|
|
402
|
+
switch (result._tag) {
|
|
403
|
+
case ExitTag.Success:
|
|
404
|
+
op = op.i1(result.value);
|
|
405
|
+
break;
|
|
406
|
+
case ExitTag.Failure:
|
|
407
|
+
op = IO.concrete(IO.failCauseNow(result.cause));
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
406
410
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
case IOTag.WhileLoop: {
|
|
421
|
-
cont.i2(oldCur.i0);
|
|
422
|
-
if (cont.i0()) {
|
|
423
|
-
this.stack.push(cont);
|
|
424
|
-
cur = IO.concrete(cont.i1());
|
|
425
|
-
} else {
|
|
426
|
-
cur = IO.concrete(IO.unit);
|
|
427
|
-
}
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
case IOTag.RevertFlags: {
|
|
431
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
|
432
|
-
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
|
433
|
-
cur = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
|
434
|
-
}
|
|
435
|
-
break;
|
|
436
|
-
}
|
|
437
|
-
case IOTag.UpdateTrace: {
|
|
438
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
|
439
|
-
cur = IO.concrete(IO.unit);
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
} else {
|
|
444
|
-
return Exit.succeed(oldCur.i0);
|
|
445
|
-
}
|
|
446
|
-
break;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
case IOTag.OnSuccessAndFailure: {
|
|
414
|
+
this.updateLastTrace(op.trace);
|
|
415
|
+
|
|
416
|
+
stackIndex = this.pushStackFrame(op, stackIndex);
|
|
417
|
+
|
|
418
|
+
const result = this.runLoop(op.i0, stackIndex, stackIndex, currentDepth + 1, ops);
|
|
419
|
+
ops += 1;
|
|
420
|
+
|
|
421
|
+
if (result === null) {
|
|
422
|
+
return null;
|
|
447
423
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
cur = IO.concrete(cont.i1(cause));
|
|
457
|
-
} else {
|
|
458
|
-
cur = IO.concrete(IO.failCauseNow(cause.stripFailures));
|
|
459
|
-
}
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
case IOTag.RevertFlags: {
|
|
463
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
|
464
|
-
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
|
465
|
-
const interruptedCause = this.getInterruptedCause();
|
|
466
|
-
if (cause.contains(interruptedCause)) {
|
|
467
|
-
cur = IO.concrete(IO.failCauseNow(cause));
|
|
468
|
-
} else {
|
|
469
|
-
cur = IO.concrete(IO.failCauseNow(Cause.sequential(cause, this.getInterruptedCause())));
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
case IOTag.UpdateTrace: {
|
|
475
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
|
476
|
-
cur = IO.concrete(IO.unit);
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
} else {
|
|
481
|
-
return Exit.failCause(cause);
|
|
424
|
+
|
|
425
|
+
stackIndex -= 1;
|
|
426
|
+
this.popStackFrame(stackIndex);
|
|
427
|
+
|
|
428
|
+
switch (result._tag) {
|
|
429
|
+
case ExitTag.Success: {
|
|
430
|
+
op = op.i2(result.value);
|
|
431
|
+
break;
|
|
482
432
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
case IOTag.WhileLoop: {
|
|
491
|
-
const iterate = cur;
|
|
492
|
-
const check = iterate.i0;
|
|
493
|
-
const body = iterate.i1;
|
|
494
|
-
if (check()) {
|
|
495
|
-
cur = IO.concrete(body());
|
|
496
|
-
this.stack.push(iterate);
|
|
497
|
-
} else {
|
|
498
|
-
cur = IO.concrete(IO.unit);
|
|
433
|
+
case ExitTag.Failure: {
|
|
434
|
+
const cause = result.cause;
|
|
435
|
+
if (this.shouldInterrupt()) {
|
|
436
|
+
op = IO.concrete(IO.failCauseNow(cause.stripFailures));
|
|
437
|
+
} else {
|
|
438
|
+
op = op.i1(result.cause);
|
|
439
|
+
}
|
|
499
440
|
}
|
|
500
|
-
break;
|
|
501
441
|
}
|
|
502
|
-
|
|
503
|
-
|
|
442
|
+
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
case IOTag.Async: {
|
|
446
|
+
this.updateLastTrace(op.trace);
|
|
447
|
+
this._blockingOn = op.i1();
|
|
448
|
+
|
|
449
|
+
op = this.initiateAsync(op.i0);
|
|
450
|
+
|
|
451
|
+
if (op === null) {
|
|
452
|
+
op = this.drainQueueAfterAsync();
|
|
504
453
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
454
|
+
|
|
455
|
+
if (op === null) {
|
|
456
|
+
return null;
|
|
508
457
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
458
|
+
|
|
459
|
+
if (this.shouldInterrupt()) {
|
|
460
|
+
op = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
|
512
461
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
462
|
+
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
case IOTag.UpdateRuntimeFlagsWithin: {
|
|
466
|
+
const trace = op.trace;
|
|
467
|
+
this.updateLastTrace(trace);
|
|
468
|
+
const updateFlags = op.i0;
|
|
469
|
+
const oldRuntimeFlags = this._runtimeFlags;
|
|
470
|
+
const newRuntimeFlags = updateFlags.patch(oldRuntimeFlags);
|
|
471
|
+
|
|
472
|
+
if (newRuntimeFlags === oldRuntimeFlags) {
|
|
473
|
+
op = IO.concrete(op.i1(oldRuntimeFlags));
|
|
474
|
+
} else {
|
|
475
|
+
if (newRuntimeFlags.interruptible && this.isInterrupted()) {
|
|
476
|
+
op = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
|
477
|
+
} else {
|
|
478
|
+
this.patchRuntimeFlagsOnly(updateFlags);
|
|
479
|
+
|
|
480
|
+
const revertFlags = newRuntimeFlags.diff(oldRuntimeFlags);
|
|
481
|
+
|
|
482
|
+
const k = IO.updateRuntimeFlags(revertFlags, trace) as UpdateRuntimeFlags;
|
|
483
|
+
|
|
484
|
+
stackIndex = this.pushStackFrame(k, stackIndex);
|
|
485
|
+
|
|
486
|
+
const exit = this.runLoop(op.i1(oldRuntimeFlags), stackIndex, stackIndex, currentDepth + 1, ops);
|
|
487
|
+
ops += 1;
|
|
488
|
+
|
|
489
|
+
if (exit === null) {
|
|
490
|
+
return null;
|
|
526
491
|
}
|
|
527
|
-
|
|
528
|
-
|
|
492
|
+
|
|
493
|
+
stackIndex -= 1;
|
|
494
|
+
this.popStackFrame(stackIndex);
|
|
495
|
+
|
|
496
|
+
op = this.patchRuntimeFlags(revertFlags, exit.causeOrNull, exit);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
case IOTag.Stateful: {
|
|
502
|
+
const trace = op.trace;
|
|
503
|
+
this.updateLastTrace(trace);
|
|
504
|
+
op = op.i0(this, FiberStatus.running(this._runtimeFlags, trace) as Running);
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
case IOTag.Fail: {
|
|
508
|
+
let cause = op.i0();
|
|
509
|
+
|
|
510
|
+
op = null;
|
|
511
|
+
|
|
512
|
+
while (op === null && stackIndex > minStackIndex) {
|
|
513
|
+
stackIndex -= 1;
|
|
514
|
+
|
|
515
|
+
const continuation = this._stack[stackIndex];
|
|
516
|
+
|
|
517
|
+
this.popStackFrame(stackIndex);
|
|
518
|
+
|
|
519
|
+
switch (continuation._ioOpCode) {
|
|
520
|
+
case IOTag.OnSuccessAndFailure: {
|
|
521
|
+
if (this.shouldInterrupt()) {
|
|
522
|
+
cause = cause.stripFailures;
|
|
523
|
+
} else {
|
|
524
|
+
op = continuation.i1(cause);
|
|
525
|
+
}
|
|
529
526
|
break;
|
|
530
527
|
}
|
|
531
|
-
case
|
|
532
|
-
|
|
528
|
+
case IOTag.UpdateRuntimeFlags:
|
|
529
|
+
op = this.patchRuntimeFlags(continuation.i0, cause, null);
|
|
533
530
|
break;
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (op === null) {
|
|
535
|
+
return Exit.failCause(cause);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
case IOTag.UpdateRuntimeFlags: {
|
|
541
|
+
this.updateLastTrace(op.trace);
|
|
542
|
+
op = this.patchRuntimeFlags(op.i0, null, IO.unit);
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
case IOTag.WhileLoop: {
|
|
546
|
+
const iterate = op;
|
|
547
|
+
this.updateLastTrace(iterate.trace);
|
|
548
|
+
const check = iterate.i0;
|
|
549
|
+
const body = iterate.i1;
|
|
550
|
+
const process = iterate.i2;
|
|
551
|
+
|
|
552
|
+
stackIndex = this.pushStackFrame(iterate, stackIndex);
|
|
553
|
+
|
|
554
|
+
op = null;
|
|
555
|
+
|
|
556
|
+
const nextDepth = currentDepth + 1;
|
|
557
|
+
|
|
558
|
+
while (op === null && check()) {
|
|
559
|
+
const exit = this.runLoop(body(), stackIndex, stackIndex, nextDepth, ops);
|
|
560
|
+
|
|
561
|
+
if (exit === null) {
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
switch (exit._tag) {
|
|
566
|
+
case ExitTag.Success:
|
|
567
|
+
process(exit.value);
|
|
537
568
|
break;
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
cur = IO.concrete(IO.service(cur));
|
|
569
|
+
case ExitTag.Failure:
|
|
570
|
+
op = IO.concrete(IO.failCauseNow(exit.cause));
|
|
541
571
|
break;
|
|
542
|
-
}
|
|
543
572
|
}
|
|
573
|
+
|
|
574
|
+
ops += 1;
|
|
544
575
|
}
|
|
576
|
+
|
|
577
|
+
stackIndex -= 1;
|
|
578
|
+
this.popStackFrame(stackIndex);
|
|
579
|
+
|
|
580
|
+
if (op === null) {
|
|
581
|
+
op = IO.concrete(IO.unit);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
break;
|
|
545
585
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
586
|
+
case IOTag.YieldNow: {
|
|
587
|
+
this.updateLastTrace(op.trace);
|
|
588
|
+
this.inbox.enqueue(FiberMessage.Resume(IO.unit));
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
case IOTag.Commit: {
|
|
592
|
+
op = IO.concrete(op.commit);
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
case IOTag.External: {
|
|
596
|
+
op = IO.concrete(op.toIO);
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
case null: {
|
|
600
|
+
switch (op._tag) {
|
|
601
|
+
case MaybeTag.Just: {
|
|
602
|
+
op = IO.concrete(IO.succeedNow(op.value));
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
case MaybeTag.Nothing: {
|
|
606
|
+
op = IO.concrete(IO.failNow(new NoSuchElementError()));
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
case EitherTag.Left: {
|
|
610
|
+
op = IO.concrete(IO.failNow(op.left));
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
case EitherTag.Right: {
|
|
614
|
+
op = IO.concrete(IO.succeedNow(op.right));
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
case ExitTag.Failure: {
|
|
618
|
+
op = IO.concrete(IO.failCauseNow(op.cause));
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
case ExitTag.Success: {
|
|
622
|
+
op = IO.concrete(IO.succeedNow(op.value));
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
case "Tag": {
|
|
626
|
+
op = IO.concrete(IO.service(op));
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
558
630
|
}
|
|
559
631
|
}
|
|
560
632
|
}
|
|
633
|
+
|
|
634
|
+
throw new Error("runLoop must exist with a return statement from within the while loop");
|
|
561
635
|
}
|
|
562
636
|
|
|
563
|
-
|
|
564
|
-
|
|
637
|
+
setFiberRef<A>(fiberRef: FiberRef<A>, value: A): void {
|
|
638
|
+
this._fiberRefs = this._fiberRefs.updateAs(this.fiberId, fiberRef, value);
|
|
565
639
|
}
|
|
566
640
|
|
|
567
|
-
|
|
568
|
-
|
|
641
|
+
setFiberRefs(fiberRefs0: FiberRefs): void {
|
|
642
|
+
this._fiberRefs = fiberRefs0;
|
|
569
643
|
}
|
|
570
644
|
|
|
571
|
-
|
|
572
|
-
if (this.
|
|
573
|
-
|
|
645
|
+
shouldYieldBeforeFork(): boolean {
|
|
646
|
+
if (this._runtimeFlags.cooperativeYielding) {
|
|
647
|
+
this._forksSinceYield += 1;
|
|
648
|
+
return this._forksSinceYield >= MAX_FORKS_BEFORE_YIELD;
|
|
574
649
|
}
|
|
575
|
-
|
|
650
|
+
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
start<R>(effect: IO<R, E, A>) {
|
|
655
|
+
let result: Exit<E, A> | null = null;
|
|
656
|
+
|
|
657
|
+
if (!this.running) {
|
|
658
|
+
try {
|
|
659
|
+
this.running = true;
|
|
660
|
+
result = this.evaluateEffect(0, IO.concrete(effect));
|
|
661
|
+
} finally {
|
|
662
|
+
this.running = false;
|
|
663
|
+
if (!this.inbox.isEmpty) {
|
|
664
|
+
this.running = true;
|
|
665
|
+
this.drainQueueLaterOnExecutor();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
this.tell(FiberMessage.Resume(effect));
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return result;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
startConcurrently(io: IO<any, E, A>): void {
|
|
676
|
+
this.tell(FiberMessage.Resume(io));
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
startFork<R>(effect: IO<R, E, A>): void {
|
|
680
|
+
this.tell(FiberMessage.Resume(effect));
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
startSuspended(): (io: IO<any, E, A>) => any {
|
|
684
|
+
let alreadyCalled = false;
|
|
685
|
+
const callback = (io: IO<any, E, A>) => {
|
|
686
|
+
if (!alreadyCalled) {
|
|
687
|
+
alreadyCalled = true;
|
|
688
|
+
this.tell(FiberMessage.Resume(io));
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
this._asyncContWith = callback;
|
|
693
|
+
|
|
694
|
+
return callback;
|
|
576
695
|
}
|
|
577
696
|
|
|
578
697
|
tell(message: FiberMessage): void {
|
|
579
|
-
this.
|
|
698
|
+
this.inbox.enqueue(message);
|
|
580
699
|
if (!this.running) {
|
|
581
700
|
this.running = true;
|
|
582
701
|
this.drainQueueLaterOnExecutor();
|
|
583
702
|
}
|
|
584
703
|
}
|
|
585
704
|
|
|
586
|
-
|
|
587
|
-
return this.
|
|
705
|
+
tellAddChild(child: FiberRuntime<any, any>): void {
|
|
706
|
+
return this.tell(FiberMessage.Stateful((parentFiber) => parentFiber.addChild(child)));
|
|
588
707
|
}
|
|
589
708
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
else this.observers = Cons(observer, this.observers);
|
|
709
|
+
tellAddChildren(children: Iterable<FiberRuntime<any, any>>): void {
|
|
710
|
+
return this.tell(FiberMessage.Stateful((parentFiber) => parentFiber.addChildren(children)));
|
|
593
711
|
}
|
|
594
712
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
this._children = new Set();
|
|
598
|
-
}
|
|
599
|
-
return this._children;
|
|
713
|
+
tellInterrupt(cause: Cause<never>): void {
|
|
714
|
+
this.tell(FiberMessage.InterruptSignal(cause));
|
|
600
715
|
}
|
|
601
716
|
|
|
602
|
-
|
|
603
|
-
|
|
717
|
+
transferChildren(scope: FiberScope) {
|
|
718
|
+
const children = this._children;
|
|
719
|
+
if (children !== null && children.size > 0) {
|
|
720
|
+
const childs = this.childrenChunk(children);
|
|
721
|
+
this._children = null!;
|
|
722
|
+
if (!childs.isEmpty) {
|
|
723
|
+
const flags = this._runtimeFlags;
|
|
724
|
+
for (const child of childs) {
|
|
725
|
+
scope.unsafeAdd(this, flags, child);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
604
729
|
}
|
|
605
730
|
|
|
606
|
-
|
|
607
|
-
this.
|
|
731
|
+
updateFiberRef<A>(fiberRef: FiberRef<A>, f: (a: A) => A): void {
|
|
732
|
+
this.setFiberRef(fiberRef, f(this.getFiberRef(fiberRef)));
|
|
608
733
|
}
|
|
609
734
|
|
|
610
|
-
private
|
|
611
|
-
const
|
|
735
|
+
private addInterruptedCause(cause: Cause<never>): void {
|
|
736
|
+
const oldSC = this.getFiberRef(FiberRef.interruptedCause);
|
|
737
|
+
if (oldSC.contains(cause)) {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
this.setFiberRef(FiberRef.interruptedCause, Cause.sequential(oldSC, cause));
|
|
741
|
+
}
|
|
612
742
|
|
|
613
|
-
|
|
743
|
+
private awaitUnsafe(trace?: string): UIO<Exit<E, A>> {
|
|
744
|
+
const exitValue = this._exitValue;
|
|
745
|
+
if (exitValue !== null) {
|
|
746
|
+
return Exit.succeed(exitValue);
|
|
747
|
+
} else {
|
|
748
|
+
return IO.asyncInterrupt<never, never, Exit<E, A>>(
|
|
749
|
+
(k) => {
|
|
750
|
+
const cb = (exit: Exit<any, any>) => k(IO.succeedNow(exit));
|
|
751
|
+
this.addObserver(cb);
|
|
752
|
+
return Either.left(IO(this.removeObserver(cb)));
|
|
753
|
+
},
|
|
754
|
+
this.id,
|
|
755
|
+
trace,
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
614
759
|
|
|
615
|
-
|
|
760
|
+
private childrenChunk(children: IterableWeakSet<FiberRuntime<any, any>>): Conc<FiberRuntime<any, any>> {
|
|
761
|
+
if (children === null) {
|
|
762
|
+
return Conc.empty();
|
|
763
|
+
}
|
|
764
|
+
const builder = Conc.builder<FiberRuntime<any, any>>();
|
|
765
|
+
children.forEach((child) => {
|
|
766
|
+
if (child !== null) {
|
|
767
|
+
builder.append(child);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
return builder.result();
|
|
616
771
|
}
|
|
617
772
|
|
|
618
|
-
private
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
773
|
+
private drainQueueAfterAsync(): IO.Concrete | null {
|
|
774
|
+
let resumption: IO.Concrete | null = null;
|
|
775
|
+
let message = this.inbox.dequeue(null!);
|
|
776
|
+
|
|
777
|
+
while (message !== null) {
|
|
778
|
+
switch (message._tag) {
|
|
779
|
+
case FiberMessageTag.InterruptSignal:
|
|
780
|
+
this.processNewInterruptSignal(message.cause);
|
|
781
|
+
break;
|
|
782
|
+
case FiberMessageTag.Stateful:
|
|
783
|
+
this.processStatefulMessage(message.onFiber);
|
|
784
|
+
break;
|
|
785
|
+
case FiberMessageTag.Resume:
|
|
786
|
+
resumption = IO.concrete(message.cont);
|
|
787
|
+
break;
|
|
627
788
|
}
|
|
628
|
-
|
|
789
|
+
|
|
790
|
+
message = this.inbox.dequeue(null!);
|
|
629
791
|
}
|
|
792
|
+
|
|
793
|
+
return resumption;
|
|
630
794
|
}
|
|
631
795
|
|
|
632
|
-
private
|
|
633
|
-
|
|
634
|
-
const iterator = this._children[Symbol.iterator]();
|
|
796
|
+
private drainQueueLaterOnExecutor(): void {
|
|
797
|
+
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
|
635
798
|
|
|
636
|
-
|
|
799
|
+
this.getFiberRef(FiberRef.currentScheduler).scheduleTask(() => this.run());
|
|
800
|
+
}
|
|
637
801
|
|
|
638
|
-
|
|
802
|
+
private drainQueueOnCurrentThread(depth: number): void {
|
|
803
|
+
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
|
639
804
|
|
|
640
|
-
|
|
641
|
-
value = iterator.next();
|
|
642
|
-
return !value.done;
|
|
643
|
-
};
|
|
805
|
+
let recurse = true;
|
|
644
806
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
807
|
+
while (recurse) {
|
|
808
|
+
let evaluationSignal = EvaluationSignal.Continue;
|
|
809
|
+
if (this._runtimeFlags.currentFiber) {
|
|
810
|
+
// TODO
|
|
811
|
+
}
|
|
812
|
+
try {
|
|
813
|
+
while (evaluationSignal === EvaluationSignal.Continue) {
|
|
814
|
+
evaluationSignal = this.inbox.isEmpty
|
|
815
|
+
? EvaluationSignal.Done
|
|
816
|
+
: this.evaluateMessageWhileSuspended(depth, this.inbox.dequeue(null!));
|
|
650
817
|
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
//
|
|
658
|
-
};
|
|
818
|
+
} finally {
|
|
819
|
+
this.running = false;
|
|
820
|
+
if (this._runtimeFlags.currentFiber) {
|
|
821
|
+
// TODO
|
|
822
|
+
}
|
|
823
|
+
}
|
|
659
824
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
825
|
+
if (!this.inbox.isEmpty && !this.running) {
|
|
826
|
+
this.running = true;
|
|
827
|
+
if (evaluationSignal === EvaluationSignal.YieldNow) {
|
|
828
|
+
this.drainQueueLaterOnExecutor();
|
|
829
|
+
recurse = false;
|
|
830
|
+
} else {
|
|
831
|
+
recurse = true;
|
|
832
|
+
}
|
|
833
|
+
} else {
|
|
834
|
+
recurse = false;
|
|
835
|
+
}
|
|
663
836
|
}
|
|
664
837
|
}
|
|
665
838
|
|
|
666
|
-
private
|
|
667
|
-
let
|
|
839
|
+
private drainQueueWhileRunning(cur0: IO.Concrete): IO<any, any, any> {
|
|
840
|
+
let cur = cur0;
|
|
668
841
|
|
|
669
|
-
|
|
670
|
-
if (!alreadyCalled) {
|
|
671
|
-
alreadyCalled = true;
|
|
672
|
-
this.tell(FiberMessage.Resume(effect));
|
|
673
|
-
}
|
|
674
|
-
};
|
|
842
|
+
let message = this.inbox.dequeue(null!);
|
|
675
843
|
|
|
676
|
-
|
|
844
|
+
while (message) {
|
|
845
|
+
switch (message._tag) {
|
|
846
|
+
case FiberMessageTag.InterruptSignal: {
|
|
847
|
+
this.updateLastTrace(cur.trace);
|
|
848
|
+
this.processNewInterruptSignal(message.cause);
|
|
849
|
+
if (this.isInterruptible()) {
|
|
850
|
+
cur = IO.concrete(IO.failCauseNow(message.cause));
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case FiberMessageTag.Stateful: {
|
|
855
|
+
this.processStatefulMessage(message.onFiber);
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
case FiberMessageTag.Resume: {
|
|
859
|
+
throw new IllegalStateError("It is illegal to have multiple concurrent run loops in a single fiber");
|
|
860
|
+
}
|
|
861
|
+
}
|
|
677
862
|
|
|
678
|
-
|
|
679
|
-
asyncRegister(callback);
|
|
680
|
-
} catch (e) {
|
|
681
|
-
callback(IO.failCauseNow(Cause.halt(e)));
|
|
863
|
+
message = this.inbox.dequeue(null!);
|
|
682
864
|
}
|
|
683
|
-
}
|
|
684
865
|
|
|
685
|
-
|
|
686
|
-
this._fiberRefs = this._fiberRefs.updateAs(this.fiberId, fiberRef, value);
|
|
866
|
+
return cur;
|
|
687
867
|
}
|
|
688
868
|
|
|
689
|
-
private
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
869
|
+
private ensureStackCapacity(size: number) {
|
|
870
|
+
const stack = this._stack;
|
|
871
|
+
const stackLength = stack.length;
|
|
872
|
+
if (stackLength < size) {
|
|
873
|
+
const newSize = (size & (size - 1)) == 0 ? size : highestOneBit(size) << 1;
|
|
874
|
+
const newStack = new Array<Continuation>(newSize);
|
|
875
|
+
copyArray(stack, 0, newStack, 0, stackLength);
|
|
876
|
+
this._stack = newStack;
|
|
693
877
|
}
|
|
694
|
-
this.setFiberRef(FiberRef.interruptedCause, Cause.sequential(oldSC, cause));
|
|
695
878
|
}
|
|
696
879
|
|
|
697
|
-
private
|
|
698
|
-
this.
|
|
699
|
-
this.
|
|
880
|
+
private evaluateEffect(initialDepth: number, effect0: IO.Concrete): Exit<E, A> | null {
|
|
881
|
+
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
|
882
|
+
this._asyncContWith = null;
|
|
883
|
+
this._blockingOn = null;
|
|
884
|
+
|
|
885
|
+
this.updateLastTrace(effect0.trace);
|
|
886
|
+
|
|
887
|
+
const supervisor = this.getSupervisor();
|
|
888
|
+
supervisor.unsafeOnResume(this);
|
|
889
|
+
|
|
890
|
+
if (this._stack === null) {
|
|
891
|
+
this._stack = new Array(INITIAL_STACK_SIZE);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
try {
|
|
895
|
+
let effect: IO.Concrete | null = effect0;
|
|
896
|
+
let finalExit: Exit<E, A> | null = null;
|
|
897
|
+
|
|
898
|
+
while (effect !== null) {
|
|
899
|
+
try {
|
|
900
|
+
if (this.shouldInterrupt()) {
|
|
901
|
+
effect = IO.concrete(IO.failCause(this.getInterruptedCause()));
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const exit = this.runLoop(effect, 0, this._stackSize, initialDepth, 0);
|
|
905
|
+
|
|
906
|
+
if (exit === null) {
|
|
907
|
+
this._forksSinceYield = 0;
|
|
908
|
+
effect = null;
|
|
909
|
+
} else {
|
|
910
|
+
this._runtimeFlags = this._runtimeFlags.enable(RuntimeFlag.WindDown);
|
|
911
|
+
const interruption = this.interruptAllChildren();
|
|
912
|
+
|
|
913
|
+
if (interruption === null) {
|
|
914
|
+
if (this.inbox.isEmpty) {
|
|
915
|
+
finalExit = exit;
|
|
916
|
+
|
|
917
|
+
supervisor.unsafeOnEnd(finalExit, this);
|
|
918
|
+
|
|
919
|
+
this.setExitValue(exit);
|
|
920
|
+
} else {
|
|
921
|
+
this.tell(FiberMessage.Resume(IO.fromExitNow(exit)));
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
effect = null;
|
|
925
|
+
} else {
|
|
926
|
+
effect = IO.concrete(interruption.flatMap(() => IO.fromExitNow(exit), this.id.location));
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
} catch (t) {
|
|
930
|
+
if (this.isFatal(t)) {
|
|
931
|
+
// TODO
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (isIOError(t)) {
|
|
935
|
+
effect = IO.concrete(IO.failCauseNow(t.cause));
|
|
936
|
+
} else {
|
|
937
|
+
effect = IO.concrete(IO.failCauseNow(Cause.halt(t)));
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
return finalExit;
|
|
943
|
+
} finally {
|
|
944
|
+
this.gcStack();
|
|
945
|
+
this.getSupervisor().unsafeOnSuspend(this);
|
|
946
|
+
}
|
|
700
947
|
}
|
|
701
948
|
|
|
702
|
-
private evaluateMessageWhileSuspended(fiberMessage: FiberMessage): EvaluationSignal {
|
|
949
|
+
private evaluateMessageWhileSuspended(depth: number, fiberMessage: FiberMessage): EvaluationSignal {
|
|
703
950
|
switch (fiberMessage._tag) {
|
|
704
951
|
case FiberMessageTag.InterruptSignal: {
|
|
705
952
|
this.processNewInterruptSignal(fiberMessage.cause);
|
|
706
953
|
|
|
707
|
-
if (this.asyncInterruptor !== null) {
|
|
708
|
-
this.asyncInterruptor(IO.failCause(fiberMessage.cause));
|
|
709
|
-
this.asyncInterruptor = null!;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
return EvaluationSignal.Continue;
|
|
713
|
-
}
|
|
714
|
-
case FiberMessageTag.GenStackTrace: {
|
|
715
|
-
fiberMessage.onTrace(this.generateStackTrace());
|
|
716
954
|
return EvaluationSignal.Continue;
|
|
717
955
|
}
|
|
718
956
|
case FiberMessageTag.Stateful: {
|
|
719
|
-
|
|
720
|
-
if (this._exitValue !== null) {
|
|
721
|
-
status = new Done();
|
|
722
|
-
} else if (this.asyncTrace === null) {
|
|
723
|
-
status = new Running(this._runtimeFlags, null!);
|
|
724
|
-
} else {
|
|
725
|
-
status = new Suspended(this._runtimeFlags, this.asyncBlockinOn, this.asyncTrace);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
fiberMessage.onFiber(this, status);
|
|
957
|
+
this.processStatefulMessage(fiberMessage.onFiber);
|
|
729
958
|
|
|
730
959
|
return EvaluationSignal.Continue;
|
|
731
960
|
}
|
|
732
961
|
case FiberMessageTag.Resume: {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
962
|
+
const nextEffect = fiberMessage.cont;
|
|
963
|
+
const exit = this.evaluateEffect(depth, IO.concrete(nextEffect));
|
|
964
|
+
if (exit === null) {
|
|
965
|
+
return EvaluationSignal.YieldNow;
|
|
966
|
+
}
|
|
967
|
+
return EvaluationSignal.Continue;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
736
971
|
|
|
737
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Removes references of entries from the stack higher than the current index
|
|
974
|
+
* so that they can be garbage collected.
|
|
975
|
+
*
|
|
976
|
+
* @note
|
|
977
|
+
* We only GC up to the {@link STACK_IDX_GC_THRESHOLD} index because
|
|
978
|
+
* we know that entries in indices higher than that have been auto-gc'd
|
|
979
|
+
* during the runloop
|
|
980
|
+
* @note
|
|
981
|
+
* This method MUST be invoked by the fiber itself while it's still running.
|
|
982
|
+
*/
|
|
983
|
+
private gcStack(): void {
|
|
984
|
+
const fromIndex = this._stackSize;
|
|
985
|
+
if (fromIndex === 0) {
|
|
986
|
+
this._stack = null!;
|
|
987
|
+
} else {
|
|
988
|
+
const stack = this._stack;
|
|
989
|
+
const toIndex = Math.min(STACK_IDX_GC_THRESHOLD, stack.length);
|
|
738
990
|
|
|
739
|
-
|
|
991
|
+
if (fromIndex < toIndex && stack[fromIndex] !== null) {
|
|
992
|
+
stack.fill(null!, fromIndex, toIndex);
|
|
740
993
|
}
|
|
741
|
-
|
|
742
|
-
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
private getStatus(): FiberStatus {
|
|
998
|
+
if (this._exitValue !== null) {
|
|
999
|
+
return FiberStatus.done;
|
|
1000
|
+
} else {
|
|
1001
|
+
if (this._asyncContWith !== null) {
|
|
1002
|
+
return FiberStatus.suspended(this._runtimeFlags, this._blockingOn ?? FiberId.none, this._lastTrace);
|
|
1003
|
+
} else {
|
|
1004
|
+
return FiberStatus.running(this._runtimeFlags, this._lastTrace);
|
|
743
1005
|
}
|
|
744
1006
|
}
|
|
745
1007
|
}
|
|
746
1008
|
|
|
747
|
-
private
|
|
748
|
-
|
|
1009
|
+
private initiateAsync(asyncRegister: (k: (_: IO<any, any, any>) => void) => any): IO.Concrete | null {
|
|
1010
|
+
let alreadyCalled = false;
|
|
749
1011
|
|
|
750
|
-
const
|
|
751
|
-
|
|
752
|
-
|
|
1012
|
+
const callback = (effect: IO<any, any, any>) => {
|
|
1013
|
+
if (!alreadyCalled) {
|
|
1014
|
+
alreadyCalled = true;
|
|
1015
|
+
this.tell(FiberMessage.Resume(effect));
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
if (this.isInterruptible()) {
|
|
1020
|
+
this._asyncContWith = callback;
|
|
1021
|
+
} else {
|
|
1022
|
+
this._asyncContWith = () => void 0;
|
|
753
1023
|
}
|
|
754
1024
|
|
|
755
|
-
|
|
756
|
-
|
|
1025
|
+
try {
|
|
1026
|
+
const sync = asyncRegister(callback);
|
|
1027
|
+
|
|
1028
|
+
if (sync != null) {
|
|
1029
|
+
if (!alreadyCalled) {
|
|
1030
|
+
alreadyCalled = true;
|
|
1031
|
+
this._asyncContWith = null;
|
|
1032
|
+
this._blockingOn = null;
|
|
1033
|
+
return sync;
|
|
1034
|
+
} else {
|
|
1035
|
+
this.log(
|
|
1036
|
+
() =>
|
|
1037
|
+
"Async operation attempted synchronous resumption, but its callback was already invoked; synchronous value will be discarded",
|
|
1038
|
+
Cause.empty(),
|
|
1039
|
+
Just(LogLevel.Error),
|
|
1040
|
+
this.id.location,
|
|
1041
|
+
);
|
|
1042
|
+
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
} else {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
} catch (t) {
|
|
1049
|
+
callback(IO.failCauseNow(Cause.halt(t)));
|
|
757
1050
|
|
|
758
|
-
|
|
759
|
-
this._exitValue = exit;
|
|
760
|
-
for (const observer of this.observers) {
|
|
761
|
-
observer(exit);
|
|
1051
|
+
return null;
|
|
762
1052
|
}
|
|
763
|
-
this.observers = List.empty();
|
|
764
1053
|
}
|
|
765
1054
|
|
|
766
|
-
|
|
767
|
-
this.
|
|
768
|
-
|
|
1055
|
+
private interruptAllChildren(): UIO<any> {
|
|
1056
|
+
if (this.sendInterruptSignalToAllChildren()) {
|
|
1057
|
+
const iterator = this._children[Symbol.iterator]();
|
|
769
1058
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
1059
|
+
this._children = null!;
|
|
1060
|
+
|
|
1061
|
+
let value: IteratorResult<FiberRuntime<any, any>>;
|
|
1062
|
+
|
|
1063
|
+
const check = () => {
|
|
1064
|
+
value = iterator.next();
|
|
1065
|
+
return !value.done;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
const body = () => {
|
|
1069
|
+
if (value != null && !value.done) {
|
|
1070
|
+
return value.value.await;
|
|
1071
|
+
} else {
|
|
1072
|
+
return IO.unit;
|
|
779
1073
|
}
|
|
780
|
-
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const io = new IOPrimitive(IOTag.WhileLoop) as any;
|
|
1077
|
+
io.i0 = check;
|
|
1078
|
+
io.i1 = body;
|
|
1079
|
+
io.i2 = () => {
|
|
1080
|
+
//
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
return io;
|
|
781
1084
|
} else {
|
|
782
|
-
|
|
1085
|
+
return null!;
|
|
783
1086
|
}
|
|
784
1087
|
}
|
|
785
1088
|
|
|
786
|
-
|
|
787
|
-
this.
|
|
1089
|
+
private isInterruptible() {
|
|
1090
|
+
return this._runtimeFlags.interruptible;
|
|
788
1091
|
}
|
|
789
1092
|
|
|
790
|
-
|
|
791
|
-
|
|
1093
|
+
private patchRuntimeFlags<R, E, A>(
|
|
1094
|
+
patch: RuntimeFlags.Patch,
|
|
1095
|
+
cause: Cause<E> | null,
|
|
1096
|
+
continueEffect: IO<R, E, A> | null,
|
|
1097
|
+
): IO.Concrete | null {
|
|
1098
|
+
const changed = this.patchRuntimeFlagsOnly(patch);
|
|
1099
|
+
const interruptEnabled = patch.isEnabled(RuntimeFlag.Interruption);
|
|
1100
|
+
|
|
1101
|
+
if (changed && interruptEnabled && this.shouldInterrupt()) {
|
|
1102
|
+
if (cause !== null) {
|
|
1103
|
+
return IO.concrete(IO.failCauseNow(Cause.sequential(cause, this.getInterruptedCause())));
|
|
1104
|
+
} else {
|
|
1105
|
+
return IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
|
1106
|
+
}
|
|
1107
|
+
} else if (cause !== null) {
|
|
1108
|
+
return IO.concrete(IO.failCauseNow(cause));
|
|
1109
|
+
} else {
|
|
1110
|
+
return IO.concrete(continueEffect!);
|
|
1111
|
+
}
|
|
792
1112
|
}
|
|
793
1113
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
1114
|
+
private patchRuntimeFlagsOnly(patch: RuntimeFlags.Patch): boolean {
|
|
1115
|
+
const oldFlags = this._runtimeFlags;
|
|
1116
|
+
const newFlags = patch.patch(oldFlags);
|
|
1117
|
+
const changed = oldFlags !== newFlags;
|
|
1118
|
+
if (changed) {
|
|
1119
|
+
if (patch.isEnabled(RuntimeFlag.CurrentFiber)) {
|
|
1120
|
+
// TODO
|
|
1121
|
+
} else {
|
|
1122
|
+
// TODO
|
|
1123
|
+
}
|
|
797
1124
|
|
|
798
|
-
|
|
799
|
-
|
|
1125
|
+
this._runtimeFlags = newFlags;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
return changed;
|
|
800
1129
|
}
|
|
801
1130
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
1131
|
+
/**
|
|
1132
|
+
* Sets the `_stackSize` to `nextStackIndex`.
|
|
1133
|
+
*
|
|
1134
|
+
* This method might also null out the entry in the stack to allow it to be
|
|
1135
|
+
* GC'd, but only if the index is >= `FiberRuntime.StackIdxGcThreshold`.
|
|
1136
|
+
*
|
|
1137
|
+
* This is based on the assumption that when the stack is shallow, the entries
|
|
1138
|
+
* in the array will keep being overwritten as the pointer moves up and down.
|
|
1139
|
+
*/
|
|
1140
|
+
private popStackFrame(nextStackIndex: number): void {
|
|
1141
|
+
if (nextStackIndex >= STACK_IDX_GC_THRESHOLD) {
|
|
1142
|
+
this._stack[nextStackIndex] = null!;
|
|
805
1143
|
}
|
|
1144
|
+
this._stackSize = nextStackIndex;
|
|
806
1145
|
}
|
|
807
1146
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1147
|
+
private processNewInterruptSignal(cause: Cause<never>): void {
|
|
1148
|
+
this.addInterruptedCause(cause);
|
|
1149
|
+
this.sendInterruptSignalToAllChildren();
|
|
811
1150
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
Logger.defaultString
|
|
818
|
-
.map((s) => console.log(s))
|
|
819
|
-
.filterLogLevel((level) => level >= LogLevel.Info)
|
|
820
|
-
.log(
|
|
821
|
-
TraceElement.parse(trace),
|
|
822
|
-
this.fiberId,
|
|
823
|
-
logLevel,
|
|
824
|
-
message,
|
|
825
|
-
cause,
|
|
826
|
-
contextMap.unFiberRefs,
|
|
827
|
-
spans,
|
|
828
|
-
annotations,
|
|
829
|
-
);
|
|
1151
|
+
const k = this._asyncContWith;
|
|
1152
|
+
|
|
1153
|
+
if (k !== null) {
|
|
1154
|
+
k(IO.failCauseNow(cause));
|
|
1155
|
+
}
|
|
830
1156
|
}
|
|
831
1157
|
|
|
832
|
-
|
|
833
|
-
|
|
1158
|
+
private processStatefulMessage(onFiber: (_: FiberRuntime<any, any>) => void): void {
|
|
1159
|
+
try {
|
|
1160
|
+
onFiber(this);
|
|
1161
|
+
} catch (t) {
|
|
1162
|
+
if (this.isFatal(t)) {
|
|
1163
|
+
// TODO
|
|
1164
|
+
} else {
|
|
1165
|
+
this.log(
|
|
1166
|
+
() => `An unexpected error was encountered while processing stateful fiber message with callback ${onFiber}`,
|
|
1167
|
+
Cause.halt(t),
|
|
1168
|
+
Just(LogLevel.Error),
|
|
1169
|
+
this.id.location,
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
834
1173
|
}
|
|
835
1174
|
|
|
836
|
-
|
|
1175
|
+
private pushStackFrame(k: Continuation, stackIndex: number): number {
|
|
1176
|
+
const newSize = stackIndex + 1;
|
|
837
1177
|
|
|
838
|
-
|
|
839
|
-
|
|
1178
|
+
this.ensureStackCapacity(newSize);
|
|
1179
|
+
|
|
1180
|
+
this._stack[stackIndex] = k;
|
|
1181
|
+
this._stackSize = newSize;
|
|
1182
|
+
|
|
1183
|
+
return newSize;
|
|
840
1184
|
}
|
|
841
1185
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
const future = Future.unsafeMake<never, Trace>(this.fiberId);
|
|
845
|
-
this.tell(FiberMessage.GenStackTrace((trace) => future.unsafeDone(IO.succeedNow(trace))));
|
|
846
|
-
return future.await;
|
|
847
|
-
});
|
|
1186
|
+
private run(): void {
|
|
1187
|
+
this.drainQueueOnCurrentThread(0);
|
|
848
1188
|
}
|
|
849
1189
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1190
|
+
private sendInterruptSignalToAllChildren(): boolean {
|
|
1191
|
+
if (this._children === null || this._children.size === 0) return false;
|
|
1192
|
+
else {
|
|
1193
|
+
let told = false;
|
|
1194
|
+
for (const child of this._children) {
|
|
1195
|
+
if (child !== null) {
|
|
1196
|
+
child.tell(FiberMessage.InterruptSignal(Cause.interrupt(this.id)));
|
|
1197
|
+
told = true;
|
|
1198
|
+
}
|
|
855
1199
|
}
|
|
1200
|
+
return told;
|
|
856
1201
|
}
|
|
857
1202
|
}
|
|
858
1203
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
return frame;
|
|
864
|
-
}
|
|
1204
|
+
private setExitValue(exit: Exit<E, A>): void {
|
|
1205
|
+
this._exitValue = exit;
|
|
1206
|
+
for (const observer of this.observers) {
|
|
1207
|
+
observer(exit);
|
|
865
1208
|
}
|
|
1209
|
+
this.observers = List.empty();
|
|
866
1210
|
}
|
|
867
1211
|
|
|
868
|
-
|
|
869
|
-
return this.
|
|
1212
|
+
private shouldInterrupt() {
|
|
1213
|
+
return this.isInterruptible() && this.isInterrupted();
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
private updateLastTrace(newTrace?: string): void {
|
|
1217
|
+
if (newTrace !== null && newTrace !== "" && this._lastTrace !== newTrace) {
|
|
1218
|
+
this._lastTrace = newTrace;
|
|
1219
|
+
}
|
|
870
1220
|
}
|
|
871
1221
|
}
|
|
872
1222
|
|
|
@@ -875,3 +1225,25 @@ const enum EvaluationSignal {
|
|
|
875
1225
|
YieldNow,
|
|
876
1226
|
Done,
|
|
877
1227
|
}
|
|
1228
|
+
|
|
1229
|
+
export function highestOneBit(i: number) {
|
|
1230
|
+
i |= i >> 1;
|
|
1231
|
+
i |= i >> 2;
|
|
1232
|
+
i |= i >> 4;
|
|
1233
|
+
i |= i >> 8;
|
|
1234
|
+
i |= i >> 16;
|
|
1235
|
+
return i - (i >>> 1);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function copyArray<A>(
|
|
1239
|
+
source: ArrayLike<A>,
|
|
1240
|
+
sourcePos: number,
|
|
1241
|
+
dest: Array<A> | Uint8Array,
|
|
1242
|
+
destPos: number,
|
|
1243
|
+
length: number,
|
|
1244
|
+
): void {
|
|
1245
|
+
const j = Math.min(source.length, sourcePos + length);
|
|
1246
|
+
for (let i = sourcePos; i < j; i++) {
|
|
1247
|
+
dest[destPos + i - sourcePos] = source[i]!;
|
|
1248
|
+
}
|
|
1249
|
+
}
|