@fncts/io 0.0.48 → 0.0.49
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/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/Random/definition.d.ts +1 -0
- package/Ref/Synchronized/api.d.ts +1 -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/Stream/api.d.ts +164 -164
- 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 +1 -2
- 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/api.cjs +2 -3
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +1 -2
- package/_cjs/Push/internal.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 +2 -3
- 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/RefSubject/Atomic.cjs +1 -2
- package/_cjs/RefSubject/Atomic.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/api.cjs +1 -2
- package/_cjs/RefSubject/Synchronized/api.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/definition.cjs +1 -2
- package/_cjs/RefSubject/Synchronized/definition.cjs.map +1 -1
- package/_cjs/RefSubject/api.cjs +1 -2
- package/_cjs/RefSubject/api.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 +1 -2
- 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/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/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 +1 -2
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/Subject/api.cjs +1 -2
- package/_cjs/Subject/api.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +2 -3
- 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/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/api.mjs +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 +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +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/Stream/api.mjs +701 -701
- package/_mjs/Stream/api.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +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/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/Random/definition.ts +1 -0
- package/_src/Ref/Synchronized/api.ts +2 -2
- package/_src/Ref/Synchronized/definition.ts +1 -1
- 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/Stream/api.ts +679 -679
- package/package.json +4 -4
- package/IO/api/sequenceT.d.ts +0 -26
- package/_cjs/IO/api/sequenceT.cjs +0 -18
- package/_cjs/IO/api/sequenceT.cjs.map +0 -1
- package/_mjs/IO/api/sequenceT.mjs +0 -10
- package/_mjs/IO/api/sequenceT.mjs.map +0 -1
- package/_src/IO/api/sequenceT.ts +0 -16
@@ -3,159 +3,703 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
7
|
-
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var
|
11
|
-
var
|
12
|
-
var
|
13
|
-
var
|
14
|
-
var
|
15
|
-
var
|
16
|
-
var
|
17
|
-
var
|
18
|
-
var
|
19
|
-
var
|
6
|
+
exports.FiberRuntime = void 0;
|
7
|
+
exports.highestOneBit = highestOneBit;
|
8
|
+
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api"));
|
9
|
+
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberRefs/api"));
|
10
|
+
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/RuntimeFlags/RuntimeFlags"));
|
11
|
+
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/RuntimeFlags/Patch"));
|
12
|
+
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
13
|
+
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberScope/constructors"));
|
14
|
+
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/List/constructors"));
|
15
|
+
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/TraceElement/definition"));
|
16
|
+
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/HashMap/api"));
|
17
|
+
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberRef/api"));
|
18
|
+
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberRef/unsafe"));
|
19
|
+
var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Exit/constructors"));
|
20
|
+
var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/Conc/constructors"));
|
21
|
+
var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Trace/constructors"));
|
22
|
+
var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Cause/api"));
|
23
|
+
var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Fiber/FiberMessage"));
|
24
|
+
var tsplus_module_17 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Cause/api/isEmpty"));
|
25
|
+
var tsplus_module_18 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Maybe/api"));
|
26
|
+
var tsplus_module_19 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/LogLevel"));
|
27
|
+
var tsplus_module_20 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Logger/constructors"));
|
28
|
+
var tsplus_module_21 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Logger/api"));
|
29
|
+
var tsplus_module_22 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/List/api"));
|
30
|
+
var tsplus_module_23 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/definition"));
|
31
|
+
var tsplus_module_24 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Exit/api"));
|
32
|
+
var tsplus_module_25 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberStatus/constructors"));
|
33
|
+
var tsplus_module_26 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/STM/api/atomically"));
|
20
34
|
var _exceptions = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/exceptions"));
|
21
|
-
var
|
22
|
-
var
|
23
|
-
var
|
24
|
-
var
|
25
|
-
var
|
26
|
-
var
|
27
|
-
var
|
28
|
-
var
|
29
|
-
var tsplus_module_22 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Cause/api/isEmpty"));
|
30
|
-
var tsplus_module_23 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/HashMap/api"));
|
31
|
-
var tsplus_module_24 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberRef/api"));
|
32
|
-
var tsplus_module_25 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/List/api"));
|
33
|
-
var tsplus_module_26 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/FiberScope/constructors"));
|
34
|
-
var tsplus_module_27 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Maybe/api"));
|
35
|
-
var tsplus_module_28 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/LogLevel"));
|
36
|
-
var tsplus_module_29 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Logger/constructors"));
|
37
|
-
var tsplus_module_30 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/Logger/api"));
|
35
|
+
var tsplus_module_27 = _exceptions;
|
36
|
+
var tsplus_module_28 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api/environment"));
|
37
|
+
var tsplus_module_29 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api"));
|
38
|
+
var tsplus_module_30 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/Either/constructors"));
|
39
|
+
var tsplus_module_31 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/io/IO/api/asyncInterrupt"));
|
40
|
+
var tsplus_module_32 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/collection/immutable/Conc/api/empty"));
|
41
|
+
var tsplus_module_33 = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("@fncts/base/data/FiberId/constructors"));
|
42
|
+
var _IterableWeakSet = /*#__PURE__*/require("@fncts/base/collection/weak/IterableWeakSet");
|
38
43
|
var _Trace = /*#__PURE__*/require("@fncts/base/data/Trace");
|
44
|
+
var _assert = /*#__PURE__*/require("@fncts/base/util/assert");
|
39
45
|
var _definition3 = /*#__PURE__*/require("@fncts/io/Fiber/definition");
|
40
46
|
var _StackTraceBuilder = /*#__PURE__*/require("@fncts/io/internal/StackTraceBuilder");
|
41
|
-
var _FiberStatus = /*#__PURE__*/require("../FiberStatus.cjs");
|
42
47
|
var _MutableQueue = /*#__PURE__*/require("../internal/MutableQueue.cjs");
|
43
48
|
var _definition4 = /*#__PURE__*/require("../IO/definition.cjs");
|
44
|
-
function
|
45
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
49
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
46
50
|
var _a;
|
47
51
|
const fileName_1 = "(@fncts/io) src/Fiber/FiberRuntime.ts";
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
this._ioOpCode = 14 /* IOTag.RevertFlags */;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
exports.RevertFlags = RevertFlags;
|
56
|
-
class UpdateTrace {
|
57
|
-
constructor(trace) {
|
58
|
-
this.trace = trace;
|
59
|
-
this._ioOpCode = 15 /* IOTag.UpdateTrace */;
|
60
|
-
}
|
61
|
-
}
|
52
|
+
const MAX_FORKS_BEFORE_YIELD = 128;
|
53
|
+
const MAX_DEPTH_BEFORE_TRAMPOLINE = 300;
|
54
|
+
const INITIAL_STACK_SIZE = 16;
|
55
|
+
const STACK_IDX_GC_THRESHOLD = 128;
|
62
56
|
/**
|
63
57
|
* @tsplus type fncts.io.Fiber
|
64
58
|
*/
|
65
|
-
exports.UpdateTrace = UpdateTrace;
|
66
59
|
class FiberRuntime {
|
60
|
+
get await() {
|
61
|
+
return tsplus_module_1.defer(() => this.awaitUnsafe(), fileName_1 + ":48:20");
|
62
|
+
}
|
63
|
+
get children() {
|
64
|
+
return tsplus_module_1.succeed(() => this.childrenChunk(this._children), fileName_1 + ":52:14");
|
65
|
+
}
|
66
|
+
get fiberRefs() {
|
67
|
+
return tsplus_module_1.succeed(() => this._fiberRefs, fileName_1 + ":56:14");
|
68
|
+
}
|
69
|
+
get id() {
|
70
|
+
return this.fiberId;
|
71
|
+
}
|
72
|
+
get inheritAll() {
|
73
|
+
return tsplus_module_1.withFiberRuntime((parentFiber, parentStatus) => {
|
74
|
+
const parentFiberId = parentFiber.id;
|
75
|
+
const parentFiberRefs = parentFiber.getFiberRefs();
|
76
|
+
const parentRuntimeFlags = parentStatus.runtimeFlags;
|
77
|
+
const childFiberRefs = this.getFiberRefs();
|
78
|
+
const updatedFiberRefs = tsplus_module_2.join(parentFiberId, childFiberRefs)(parentFiberRefs);
|
79
|
+
parentFiber.setFiberRefs(updatedFiberRefs);
|
80
|
+
return tsplus_module_1.flatMap(childRuntimeFlags => {
|
81
|
+
const patch = tsplus_module_4.exclude(tsplus_module_4.exclude(tsplus_module_3.diff(parentRuntimeFlags, childRuntimeFlags), 64 /* RuntimeFlag.WindDown */), 1 /* RuntimeFlag.Interruption */);
|
82
|
+
return tsplus_module_1.updateRuntimeFlags(patch, fileName_1 + ":80:37");
|
83
|
+
}, fileName_1 + ":74:39")(this.runtimeFlags);
|
84
|
+
}, fileName_1 + ":64:31");
|
85
|
+
}
|
86
|
+
get poll() {
|
87
|
+
return tsplus_module_1.succeed(() => tsplus_module_5.fromNullable(this.exitValue()), fileName_1 + ":86:22");
|
88
|
+
}
|
89
|
+
get runtimeFlags() {
|
90
|
+
return tsplus_module_1.succeed(() => this._runtimeFlags, fileName_1 + ":90:14");
|
91
|
+
}
|
92
|
+
get scope() {
|
93
|
+
return tsplus_module_6.unsafeMake(this);
|
94
|
+
}
|
95
|
+
get status() {
|
96
|
+
return tsplus_module_1.succeed(() => this.getStatus(), fileName_1 + ":98:14");
|
97
|
+
}
|
98
|
+
get trace() {
|
99
|
+
return tsplus_module_1.succeed(() => this.generateStackTrace(), fileName_1 + ":102:14");
|
100
|
+
}
|
67
101
|
constructor(fiberId, fiberRefs0, runtimeFlags0) {
|
68
102
|
this.fiberId = fiberId;
|
69
103
|
this.runtimeFlags0 = runtimeFlags0;
|
70
|
-
this[_a] = _definition3.FiberTypeId;
|
71
104
|
this._tag = "RuntimeFiber";
|
72
|
-
this
|
105
|
+
this[_a] = _definition3.FiberTypeId;
|
106
|
+
this.location = this.fiberId.location;
|
107
|
+
this._asyncContWith = null;
|
108
|
+
this._blockingOn = null;
|
73
109
|
this._children = null;
|
74
|
-
this.observers = tsplus_module_1.make();
|
75
|
-
this.running = false;
|
76
|
-
this.stack = new tsplus_module_2.Stack();
|
77
|
-
this.asyncInterruptor = null;
|
78
|
-
this.asyncTrace = null;
|
79
|
-
this.asyncBlockinOn = null;
|
80
110
|
this._exitValue = null;
|
81
|
-
this.
|
111
|
+
this._forksSinceYield = 0;
|
112
|
+
this._stack = null;
|
113
|
+
this._stackSize = 0;
|
114
|
+
this.inbox = new _MutableQueue.LinkedQueue();
|
115
|
+
this.observers = tsplus_module_7.make();
|
116
|
+
this.running = false;
|
82
117
|
this._fiberRefs = fiberRefs0;
|
83
118
|
this._runtimeFlags = runtimeFlags0;
|
84
119
|
}
|
85
|
-
|
86
|
-
|
120
|
+
addChild(child) {
|
121
|
+
this.getChildren().add(child);
|
87
122
|
}
|
88
|
-
|
89
|
-
|
90
|
-
const
|
91
|
-
|
92
|
-
|
93
|
-
|
123
|
+
addChildren(children) {
|
124
|
+
if (this.isAlive()) {
|
125
|
+
const childs = this.getChildren();
|
126
|
+
if (this.shouldInterrupt()) {
|
127
|
+
const cause = this.getInterruptedCause();
|
128
|
+
for (const child of children) {
|
129
|
+
if (child.isAlive()) {
|
130
|
+
childs.add(child);
|
131
|
+
child.tellInterrupt(cause);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
} else {
|
135
|
+
for (const child of children) {
|
136
|
+
if (child.isAlive()) {
|
137
|
+
childs.add(child);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
const cause = this.getInterruptedCause();
|
143
|
+
for (const child of children) {
|
144
|
+
if (child.isAlive()) {
|
145
|
+
child.tellInterrupt(cause);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
94
149
|
}
|
95
|
-
|
96
|
-
|
97
|
-
if (fiber._exitValue !== null) cb(tsplus_module_4.succeedNow(fiber.exitValue(), fileName_1 + ":89:60"));else fiber.addObserver(exit => cb(tsplus_module_4.succeedNow(exit, fileName_1 + ":90:62")));
|
98
|
-
})), this.id, fileName_1 + ":85:20");
|
150
|
+
addObserver(observer) {
|
151
|
+
if (this._exitValue !== null) observer(this._exitValue);else this.observers = tsplus_module_7.cons(observer, this.observers);
|
99
152
|
}
|
100
|
-
|
101
|
-
|
153
|
+
deleteFiberRef(ref) {
|
154
|
+
this._fiberRefs = tsplus_module_2.remove(this._fiberRefs, ref);
|
102
155
|
}
|
103
|
-
|
104
|
-
return this.
|
156
|
+
exitValue() {
|
157
|
+
return this._exitValue;
|
105
158
|
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}
|
159
|
+
generateStackTrace() {
|
160
|
+
const builder = new _StackTraceBuilder.StackTraceBuilder();
|
161
|
+
const stack = this._stack;
|
162
|
+
const size = this._stackSize;
|
163
|
+
if (stack !== null) {
|
164
|
+
for (let i = stack.length < size ? stack.length : size; i >= 0; i--) {
|
165
|
+
const k = stack[i];
|
166
|
+
if (k != null) {
|
167
|
+
builder.append(tsplus_module_8.parse(k.trace));
|
168
|
+
}
|
169
|
+
}
|
170
|
+
builder.append(tsplus_module_8.parse(this.id.location));
|
171
|
+
}
|
172
|
+
return new _Trace.Trace(this.fiberId, builder.result());
|
119
173
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
174
|
+
getChildren() {
|
175
|
+
let children = this._children;
|
176
|
+
if (children === null) {
|
177
|
+
children = new _IterableWeakSet.IterableWeakSet();
|
178
|
+
this._children = children;
|
179
|
+
}
|
180
|
+
return children;
|
124
181
|
}
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
182
|
+
getFiberRef(fiberRef) {
|
183
|
+
if (tsplus_module_9.has(fiberRef)(this._fiberRefs)) {
|
184
|
+
return tsplus_module_9.unsafeGet(fiberRef)(this._fiberRefs).head[1];
|
185
|
+
}
|
186
|
+
return tsplus_module_10.initial(fiberRef);
|
187
|
+
}
|
188
|
+
getFiberRefs() {
|
189
|
+
return this._fiberRefs;
|
190
|
+
}
|
191
|
+
getInterruptedCause() {
|
192
|
+
return this.getFiberRef(tsplus_module_11.interruptedCause);
|
130
193
|
}
|
131
194
|
getSupervisor() {
|
132
|
-
return this.getFiberRef(
|
195
|
+
return this.getFiberRef(tsplus_module_11.currentSupervisor);
|
133
196
|
}
|
134
|
-
|
135
|
-
return
|
197
|
+
interruptAs(fiberId, __tsplusTrace) {
|
198
|
+
return tsplus_module_1.defer(() => {
|
199
|
+
const exit = this._exitValue;
|
200
|
+
if (exit !== null) {
|
201
|
+
return tsplus_module_12.succeed(exit, fileName_1 + ":224:28");
|
202
|
+
} else {
|
203
|
+
const cause = tsplus_module_15.interrupt(fiberId, tsplus_module_14.make(this.fiberId, tsplus_module_13.single(tsplus_module_8.parse(__tsplusTrace))));
|
204
|
+
this.tell(tsplus_module_16.interruptSignal(cause));
|
205
|
+
return this.awaitUnsafe(__tsplusTrace);
|
206
|
+
}
|
207
|
+
}, fileName_1 + ":221:20");
|
136
208
|
}
|
137
|
-
|
138
|
-
|
209
|
+
interruptAsFork(fiberId, __tsplusTrace) {
|
210
|
+
return tsplus_module_1.succeed(() => {
|
211
|
+
const cause = tsplus_module_15.interrupt(fiberId);
|
212
|
+
this.tell(tsplus_module_16.interruptSignal(cause));
|
213
|
+
}, fileName_1 + ":234:22");
|
214
|
+
}
|
215
|
+
isAlive() {
|
216
|
+
return this.exitValue === null;
|
217
|
+
}
|
218
|
+
isDone() {
|
219
|
+
return this.exitValue !== null;
|
220
|
+
}
|
221
|
+
isFatal(t) {
|
222
|
+
return this.getFiberRef(tsplus_module_11.currentIsFatal).apply(t);
|
223
|
+
}
|
224
|
+
isInterrupted() {
|
225
|
+
return !tsplus_module_17.isEmpty(this.getFiberRef(tsplus_module_11.interruptedCause));
|
226
|
+
}
|
227
|
+
log(message, cause, overrideLogLevel, trace) {
|
228
|
+
const logLevel = tsplus_module_18.getOrElse(() => this.getFiberRef(tsplus_module_11.currentLogLevel))(overrideLogLevel);
|
229
|
+
const spans = this.getFiberRef(tsplus_module_11.currentLogSpan);
|
230
|
+
const annotations = this.getFiberRef(tsplus_module_11.currentLogAnnotations);
|
231
|
+
const contextMap = this.getFiberRefs();
|
232
|
+
tsplus_module_21.filterLogLevel(level => tsplus_module_19.gte(tsplus_module_19.Info)(level))(tsplus_module_21.map(s => console.log(s))(tsplus_module_20.defaultString)).log(tsplus_module_8.parse(trace), this.fiberId, logLevel, message, cause, contextMap, spans, annotations);
|
233
|
+
}
|
234
|
+
removeChild(child) {
|
235
|
+
if (this._children !== null) {
|
236
|
+
this._children.delete(child);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
removeObserver(observer) {
|
240
|
+
this.observers = tsplus_module_22.filter(f => f !== observer)(this.observers);
|
241
|
+
}
|
242
|
+
resume(effect) {
|
243
|
+
this.tell(tsplus_module_16.resume(effect));
|
244
|
+
}
|
245
|
+
runLoop(effect, minStackIndex, startStackIndex, currentDepth, currentOps) {
|
246
|
+
(0, _assert.assert)(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
247
|
+
let op = effect;
|
248
|
+
let ops = currentOps;
|
249
|
+
let stackIndex = startStackIndex;
|
250
|
+
if (currentDepth >= MAX_DEPTH_BEFORE_TRAMPOLINE) {
|
251
|
+
this.inbox.enqueue(tsplus_module_16.resume(effect));
|
252
|
+
return null;
|
253
|
+
}
|
254
|
+
while (true) {
|
255
|
+
if ((this._runtimeFlags & 8 /* RuntimeFlag.OpSupervision */) !== 0) {
|
256
|
+
this.getSupervisor().unsafeOnEffect(this, op);
|
257
|
+
}
|
258
|
+
op = this.drainQueueWhileRunning(op);
|
259
|
+
ops += 1;
|
260
|
+
if (ops > this.getFiberRef(tsplus_module_11.currentMaxFiberOps)) {
|
261
|
+
this.updateLastTrace(op.trace);
|
262
|
+
this.inbox.enqueue(tsplus_module_16.resume(op));
|
263
|
+
return null;
|
264
|
+
}
|
265
|
+
switch (op._ioOpCode) {
|
266
|
+
case 0 /* IOTag.SucceedNow */:
|
267
|
+
{
|
268
|
+
const value = op.i0;
|
269
|
+
op = null;
|
270
|
+
while (op === null && stackIndex > minStackIndex) {
|
271
|
+
stackIndex -= 1;
|
272
|
+
const continuation = this._stack[stackIndex];
|
273
|
+
this.popStackFrame(stackIndex);
|
274
|
+
switch (continuation._ioOpCode) {
|
275
|
+
case 5 /* IOTag.OnSuccess */:
|
276
|
+
op = continuation.i1(value);
|
277
|
+
break;
|
278
|
+
case 4 /* IOTag.OnSuccessAndFailure */:
|
279
|
+
op = continuation.i2(value);
|
280
|
+
break;
|
281
|
+
case 6 /* IOTag.UpdateRuntimeFlags */:
|
282
|
+
op = this.patchRuntimeFlags(continuation.i0, null, null);
|
283
|
+
break;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
if (op === null) {
|
287
|
+
return tsplus_module_12.succeed(value, fileName_1 + ":348:32");
|
288
|
+
}
|
289
|
+
break;
|
290
|
+
}
|
291
|
+
case 2 /* IOTag.Sync */:
|
292
|
+
{
|
293
|
+
this.updateLastTrace(op.trace);
|
294
|
+
const value = op.i0();
|
295
|
+
op = null;
|
296
|
+
while (op === null && stackIndex > minStackIndex) {
|
297
|
+
stackIndex -= 1;
|
298
|
+
const continuation = this._stack[stackIndex];
|
299
|
+
this.popStackFrame(stackIndex);
|
300
|
+
switch (continuation._ioOpCode) {
|
301
|
+
case 5 /* IOTag.OnSuccess */:
|
302
|
+
op = continuation.i1(value);
|
303
|
+
break;
|
304
|
+
case 4 /* IOTag.OnSuccessAndFailure */:
|
305
|
+
op = continuation.i2(value);
|
306
|
+
break;
|
307
|
+
case 6 /* IOTag.UpdateRuntimeFlags */:
|
308
|
+
op = this.patchRuntimeFlags(continuation.i0, null, null);
|
309
|
+
break;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
if (op === null) {
|
313
|
+
return tsplus_module_12.succeed(value, fileName_1 + ":378:32");
|
314
|
+
}
|
315
|
+
break;
|
316
|
+
}
|
317
|
+
case 5 /* IOTag.OnSuccess */:
|
318
|
+
{
|
319
|
+
this.updateLastTrace(op.trace);
|
320
|
+
const first = op.i0;
|
321
|
+
if (first === tsplus_module_1.unit) {
|
322
|
+
op = op.i1(undefined);
|
323
|
+
} else {
|
324
|
+
stackIndex = this.pushStackFrame(op, stackIndex);
|
325
|
+
const result = this.runLoop(first, stackIndex, stackIndex, currentDepth + 1, ops);
|
326
|
+
ops += 1;
|
327
|
+
if (result === null) {
|
328
|
+
return null;
|
329
|
+
}
|
330
|
+
stackIndex -= 1;
|
331
|
+
this.popStackFrame(stackIndex);
|
332
|
+
switch (result._tag) {
|
333
|
+
case "Success" /* ExitTag.Success */:
|
334
|
+
op = op.i1(result.value);
|
335
|
+
break;
|
336
|
+
case "Failure" /* ExitTag.Failure */:
|
337
|
+
op = tsplus_module_1.failCauseNow(result.cause, fileName_1 + ":407:49");
|
338
|
+
break;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
break;
|
342
|
+
}
|
343
|
+
case 4 /* IOTag.OnSuccessAndFailure */:
|
344
|
+
{
|
345
|
+
this.updateLastTrace(op.trace);
|
346
|
+
stackIndex = this.pushStackFrame(op, stackIndex);
|
347
|
+
const result = this.runLoop(op.i0, stackIndex, stackIndex, currentDepth + 1, ops);
|
348
|
+
ops += 1;
|
349
|
+
if (result === null) {
|
350
|
+
return null;
|
351
|
+
}
|
352
|
+
stackIndex -= 1;
|
353
|
+
this.popStackFrame(stackIndex);
|
354
|
+
switch (result._tag) {
|
355
|
+
case "Success" /* ExitTag.Success */:
|
356
|
+
{
|
357
|
+
op = op.i2(result.value);
|
358
|
+
break;
|
359
|
+
}
|
360
|
+
case "Failure" /* ExitTag.Failure */:
|
361
|
+
{
|
362
|
+
const cause = result.cause;
|
363
|
+
if (this.shouldInterrupt()) {
|
364
|
+
op = tsplus_module_1.failCauseNow(tsplus_module_15.stripFailures(cause), fileName_1 + ":436:49");
|
365
|
+
} else {
|
366
|
+
op = op.i1(result.cause);
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}
|
370
|
+
break;
|
371
|
+
}
|
372
|
+
case 3 /* IOTag.Async */:
|
373
|
+
{
|
374
|
+
this.updateLastTrace(op.trace);
|
375
|
+
this._blockingOn = op.i1();
|
376
|
+
op = this.initiateAsync(op.i0);
|
377
|
+
if (op === null) {
|
378
|
+
op = this.drainQueueAfterAsync();
|
379
|
+
}
|
380
|
+
if (op === null) {
|
381
|
+
return null;
|
382
|
+
}
|
383
|
+
if (this.shouldInterrupt()) {
|
384
|
+
op = tsplus_module_1.failCauseNow(this.getInterruptedCause(), fileName_1 + ":460:45");
|
385
|
+
}
|
386
|
+
break;
|
387
|
+
}
|
388
|
+
case 7 /* IOTag.UpdateRuntimeFlagsWithin */:
|
389
|
+
{
|
390
|
+
const trace = op.trace;
|
391
|
+
this.updateLastTrace(trace);
|
392
|
+
const updateFlags = op.i0;
|
393
|
+
const oldRuntimeFlags = this._runtimeFlags;
|
394
|
+
const newRuntimeFlags = tsplus_module_4.patch(updateFlags, oldRuntimeFlags);
|
395
|
+
if (newRuntimeFlags === oldRuntimeFlags) {
|
396
|
+
op = op.i1(oldRuntimeFlags);
|
397
|
+
} else {
|
398
|
+
if (tsplus_module_3.interruptible(newRuntimeFlags) && this.isInterrupted()) {
|
399
|
+
op = tsplus_module_1.failCauseNow(this.getInterruptedCause(), fileName_1 + ":476:47");
|
400
|
+
} else {
|
401
|
+
this.patchRuntimeFlagsOnly(updateFlags);
|
402
|
+
const revertFlags = tsplus_module_3.diff(newRuntimeFlags, oldRuntimeFlags);
|
403
|
+
const k = tsplus_module_1.updateRuntimeFlags(revertFlags, trace);
|
404
|
+
stackIndex = this.pushStackFrame(k, stackIndex);
|
405
|
+
const exit = this.runLoop(op.i1(oldRuntimeFlags), stackIndex, stackIndex, currentDepth + 1, ops);
|
406
|
+
ops += 1;
|
407
|
+
if (exit === null) {
|
408
|
+
return null;
|
409
|
+
}
|
410
|
+
stackIndex -= 1;
|
411
|
+
this.popStackFrame(stackIndex);
|
412
|
+
op = this.patchRuntimeFlags(revertFlags, tsplus_module_24.causeOrNull(exit), exit);
|
413
|
+
}
|
414
|
+
}
|
415
|
+
break;
|
416
|
+
}
|
417
|
+
case 8 /* IOTag.Stateful */:
|
418
|
+
{
|
419
|
+
const trace = op.trace;
|
420
|
+
this.updateLastTrace(trace);
|
421
|
+
op = op.i0(this, tsplus_module_25.running(this._runtimeFlags, trace));
|
422
|
+
break;
|
423
|
+
}
|
424
|
+
case 1 /* IOTag.Fail */:
|
425
|
+
{
|
426
|
+
let cause = op.i0();
|
427
|
+
op = null;
|
428
|
+
while (op === null && stackIndex > minStackIndex) {
|
429
|
+
stackIndex -= 1;
|
430
|
+
const continuation = this._stack[stackIndex];
|
431
|
+
this.popStackFrame(stackIndex);
|
432
|
+
switch (continuation._ioOpCode) {
|
433
|
+
case 4 /* IOTag.OnSuccessAndFailure */:
|
434
|
+
{
|
435
|
+
if (this.shouldInterrupt()) {
|
436
|
+
cause = tsplus_module_15.stripFailures(cause);
|
437
|
+
} else {
|
438
|
+
op = continuation.i1(cause);
|
439
|
+
}
|
440
|
+
break;
|
441
|
+
}
|
442
|
+
case 6 /* IOTag.UpdateRuntimeFlags */:
|
443
|
+
op = this.patchRuntimeFlags(continuation.i0, cause, null);
|
444
|
+
break;
|
445
|
+
}
|
446
|
+
}
|
447
|
+
if (op === null) {
|
448
|
+
return tsplus_module_12.failCause(cause, fileName_1 + ":535:34");
|
449
|
+
}
|
450
|
+
break;
|
451
|
+
}
|
452
|
+
case 6 /* IOTag.UpdateRuntimeFlags */:
|
453
|
+
{
|
454
|
+
this.updateLastTrace(op.trace);
|
455
|
+
op = this.patchRuntimeFlags(op.i0, null, tsplus_module_1.unit);
|
456
|
+
break;
|
457
|
+
}
|
458
|
+
case 9 /* IOTag.WhileLoop */:
|
459
|
+
{
|
460
|
+
const iterate = op;
|
461
|
+
this.updateLastTrace(iterate.trace);
|
462
|
+
const check = iterate.i0;
|
463
|
+
const body = iterate.i1;
|
464
|
+
const process = iterate.i2;
|
465
|
+
stackIndex = this.pushStackFrame(iterate, stackIndex);
|
466
|
+
op = null;
|
467
|
+
const nextDepth = currentDepth + 1;
|
468
|
+
while (op === null && check()) {
|
469
|
+
const exit = this.runLoop(body(), stackIndex, stackIndex, nextDepth, ops);
|
470
|
+
if (exit === null) {
|
471
|
+
return null;
|
472
|
+
}
|
473
|
+
switch (exit._tag) {
|
474
|
+
case "Success" /* ExitTag.Success */:
|
475
|
+
process(exit.value);
|
476
|
+
break;
|
477
|
+
case "Failure" /* ExitTag.Failure */:
|
478
|
+
op = tsplus_module_1.failCauseNow(exit.cause, fileName_1 + ":570:49");
|
479
|
+
break;
|
480
|
+
}
|
481
|
+
ops += 1;
|
482
|
+
}
|
483
|
+
stackIndex -= 1;
|
484
|
+
this.popStackFrame(stackIndex);
|
485
|
+
if (op === null) {
|
486
|
+
op = tsplus_module_1.unit;
|
487
|
+
}
|
488
|
+
break;
|
489
|
+
}
|
490
|
+
case 10 /* IOTag.YieldNow */:
|
491
|
+
{
|
492
|
+
this.updateLastTrace(op.trace);
|
493
|
+
this.inbox.enqueue(tsplus_module_16.resume(tsplus_module_1.unit));
|
494
|
+
return null;
|
495
|
+
}
|
496
|
+
case 11 /* IOTag.Commit */:
|
497
|
+
{
|
498
|
+
op = tsplus_module_26.atomically(op, fileName_1 + ":592:30");
|
499
|
+
break;
|
500
|
+
}
|
501
|
+
case 13 /* IOTag.External */:
|
502
|
+
{
|
503
|
+
op = op.toIO;
|
504
|
+
break;
|
505
|
+
}
|
506
|
+
case null:
|
507
|
+
{
|
508
|
+
switch (op._tag) {
|
509
|
+
case "Just" /* MaybeTag.Just */:
|
510
|
+
{
|
511
|
+
op = tsplus_module_1.succeedNow(op.value, fileName_1 + ":602:45");
|
512
|
+
break;
|
513
|
+
}
|
514
|
+
case "Nothing" /* MaybeTag.Nothing */:
|
515
|
+
{
|
516
|
+
op = tsplus_module_1.failNow(new tsplus_module_27.NoSuchElementError(), fileName_1 + ":606:42");
|
517
|
+
break;
|
518
|
+
}
|
519
|
+
case "Left" /* EitherTag.Left */:
|
520
|
+
{
|
521
|
+
op = tsplus_module_1.failNow(op.left, fileName_1 + ":610:42");
|
522
|
+
break;
|
523
|
+
}
|
524
|
+
case "Right" /* EitherTag.Right */:
|
525
|
+
{
|
526
|
+
op = tsplus_module_1.succeedNow(op.right, fileName_1 + ":614:45");
|
527
|
+
break;
|
528
|
+
}
|
529
|
+
case "Failure" /* ExitTag.Failure */:
|
530
|
+
{
|
531
|
+
op = tsplus_module_1.failCauseNow(op.cause, fileName_1 + ":618:47");
|
532
|
+
break;
|
533
|
+
}
|
534
|
+
case "Success" /* ExitTag.Success */:
|
535
|
+
{
|
536
|
+
op = tsplus_module_1.succeedNow(op.value, fileName_1 + ":622:45");
|
537
|
+
break;
|
538
|
+
}
|
539
|
+
case "Tag":
|
540
|
+
{
|
541
|
+
op = tsplus_module_28.service(op, fileName_1 + ":626:42");
|
542
|
+
break;
|
543
|
+
}
|
544
|
+
}
|
545
|
+
}
|
546
|
+
}
|
547
|
+
}
|
548
|
+
throw new Error("runLoop must exist with a return statement from within the while loop");
|
549
|
+
}
|
550
|
+
setFiberRef(fiberRef, value) {
|
551
|
+
this._fiberRefs = tsplus_module_2.updateAs(this._fiberRefs, this.fiberId, fiberRef, value);
|
552
|
+
}
|
553
|
+
setFiberRefs(fiberRefs0) {
|
554
|
+
this._fiberRefs = fiberRefs0;
|
555
|
+
}
|
556
|
+
shouldYieldBeforeFork() {
|
557
|
+
if (tsplus_module_3.cooperativeYielding(this._runtimeFlags)) {
|
558
|
+
this._forksSinceYield += 1;
|
559
|
+
return this._forksSinceYield >= MAX_FORKS_BEFORE_YIELD;
|
560
|
+
}
|
561
|
+
return false;
|
562
|
+
}
|
563
|
+
start(effect) {
|
564
|
+
let result = null;
|
565
|
+
if (!this.running) {
|
566
|
+
try {
|
567
|
+
this.running = true;
|
568
|
+
result = this.evaluateEffect(0, effect);
|
569
|
+
} finally {
|
570
|
+
this.running = false;
|
571
|
+
if (!this.inbox.isEmpty) {
|
572
|
+
this.running = true;
|
573
|
+
this.drainQueueLaterOnExecutor();
|
574
|
+
}
|
575
|
+
}
|
576
|
+
} else {
|
577
|
+
this.tell(tsplus_module_16.resume(effect));
|
578
|
+
}
|
579
|
+
return result;
|
580
|
+
}
|
581
|
+
startConcurrently(io) {
|
582
|
+
this.tell(tsplus_module_16.resume(io));
|
583
|
+
}
|
584
|
+
startFork(effect) {
|
585
|
+
this.tell(tsplus_module_16.resume(effect));
|
586
|
+
}
|
587
|
+
startSuspended() {
|
588
|
+
let alreadyCalled = false;
|
589
|
+
const callback = io => {
|
590
|
+
if (!alreadyCalled) {
|
591
|
+
alreadyCalled = true;
|
592
|
+
this.tell(tsplus_module_16.resume(io));
|
593
|
+
}
|
594
|
+
};
|
595
|
+
this._asyncContWith = callback;
|
596
|
+
return callback;
|
597
|
+
}
|
598
|
+
tell(message) {
|
599
|
+
this.inbox.enqueue(message);
|
600
|
+
if (!this.running) {
|
601
|
+
this.running = true;
|
602
|
+
this.drainQueueLaterOnExecutor();
|
603
|
+
}
|
604
|
+
}
|
605
|
+
tellAddChild(child) {
|
606
|
+
return this.tell(tsplus_module_16.stateful(parentFiber => parentFiber.addChild(child)));
|
607
|
+
}
|
608
|
+
tellAddChildren(children) {
|
609
|
+
return this.tell(tsplus_module_16.stateful(parentFiber => parentFiber.addChildren(children)));
|
610
|
+
}
|
611
|
+
tellInterrupt(cause) {
|
612
|
+
this.tell(tsplus_module_16.interruptSignal(cause));
|
613
|
+
}
|
614
|
+
transferChildren(scope) {
|
615
|
+
const children = this._children;
|
616
|
+
if (children !== null && children.size > 0) {
|
617
|
+
const childs = this.childrenChunk(children);
|
618
|
+
this._children = null;
|
619
|
+
if (!tsplus_module_29.isEmpty(childs)) {
|
620
|
+
const flags = this._runtimeFlags;
|
621
|
+
for (const child of childs) {
|
622
|
+
scope.unsafeAdd(this, flags, child);
|
623
|
+
}
|
624
|
+
}
|
625
|
+
}
|
626
|
+
}
|
627
|
+
updateFiberRef(fiberRef, f) {
|
628
|
+
this.setFiberRef(fiberRef, f(this.getFiberRef(fiberRef)));
|
629
|
+
}
|
630
|
+
addInterruptedCause(cause) {
|
631
|
+
const oldSC = this.getFiberRef(tsplus_module_11.interruptedCause);
|
632
|
+
if (tsplus_module_15.contains(cause)(oldSC)) {
|
633
|
+
return;
|
634
|
+
}
|
635
|
+
this.setFiberRef(tsplus_module_11.interruptedCause, tsplus_module_15.sequential(oldSC, cause));
|
636
|
+
}
|
637
|
+
awaitUnsafe(trace) {
|
638
|
+
const exitValue = this._exitValue;
|
639
|
+
if (exitValue !== null) {
|
640
|
+
return tsplus_module_12.succeed(exitValue, fileName_1 + ":746:26");
|
641
|
+
} else {
|
642
|
+
return tsplus_module_31.asyncInterrupt(k => {
|
643
|
+
const cb = exit => k(tsplus_module_1.succeedNow(exit, fileName_1 + ":750:63"));
|
644
|
+
this.addObserver(cb);
|
645
|
+
return tsplus_module_30.left(tsplus_module_1.succeed(() => this.removeObserver(cb), fileName_1 + ":752:32"), fileName_1 + ":752:29");
|
646
|
+
}, this.id, trace);
|
647
|
+
}
|
648
|
+
}
|
649
|
+
childrenChunk(children) {
|
650
|
+
if (children === null) {
|
651
|
+
return tsplus_module_32.empty();
|
652
|
+
}
|
653
|
+
const builder = tsplus_module_29.builder();
|
654
|
+
children.forEach(child => {
|
655
|
+
if (child !== null) {
|
656
|
+
builder.append(child);
|
657
|
+
}
|
658
|
+
});
|
659
|
+
return builder.result();
|
660
|
+
}
|
661
|
+
drainQueueAfterAsync() {
|
662
|
+
let resumption = null;
|
663
|
+
let message = this.inbox.dequeue(null);
|
664
|
+
while (message !== null) {
|
665
|
+
switch (message._tag) {
|
666
|
+
case 0 /* FiberMessageTag.InterruptSignal */:
|
667
|
+
this.processNewInterruptSignal(message.cause);
|
668
|
+
break;
|
669
|
+
case 1 /* FiberMessageTag.Stateful */:
|
670
|
+
this.processStatefulMessage(message.onFiber);
|
671
|
+
break;
|
672
|
+
case 2 /* FiberMessageTag.Resume */:
|
673
|
+
resumption = message.cont;
|
674
|
+
break;
|
675
|
+
}
|
676
|
+
message = this.inbox.dequeue(null);
|
677
|
+
}
|
678
|
+
return resumption;
|
679
|
+
}
|
680
|
+
drainQueueLaterOnExecutor() {
|
681
|
+
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
682
|
+
this.getFiberRef(tsplus_module_11.currentScheduler).scheduleTask(() => this.run());
|
139
683
|
}
|
140
|
-
drainQueueOnCurrentThread() {
|
684
|
+
drainQueueOnCurrentThread(depth) {
|
141
685
|
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
142
686
|
let recurse = true;
|
143
687
|
while (recurse) {
|
144
688
|
let evaluationSignal = 0 /* EvaluationSignal.Continue */;
|
145
|
-
if (
|
689
|
+
if (tsplus_module_3.currentFiber(this._runtimeFlags)) {
|
146
690
|
// TODO
|
147
691
|
}
|
148
692
|
try {
|
149
693
|
while (evaluationSignal === 0 /* EvaluationSignal.Continue */) {
|
150
|
-
evaluationSignal = this.
|
694
|
+
evaluationSignal = this.inbox.isEmpty ? 2 /* EvaluationSignal.Done */ : this.evaluateMessageWhileSuspended(depth, this.inbox.dequeue(null));
|
151
695
|
}
|
152
696
|
} finally {
|
153
697
|
this.running = false;
|
154
|
-
if (
|
698
|
+
if (tsplus_module_3.currentFiber(this._runtimeFlags)) {
|
155
699
|
// TODO
|
156
700
|
}
|
157
701
|
}
|
158
|
-
if (!this.
|
702
|
+
if (!this.inbox.isEmpty && !this.running) {
|
159
703
|
this.running = true;
|
160
704
|
if (evaluationSignal === 1 /* EvaluationSignal.YieldNow */) {
|
161
705
|
this.drainQueueLaterOnExecutor();
|
@@ -168,441 +712,187 @@ class FiberRuntime {
|
|
168
712
|
}
|
169
713
|
}
|
170
714
|
}
|
171
|
-
|
172
|
-
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
173
|
-
this.getFiberRef(tsplus_module_12.currentScheduler).scheduleTask(() => this.run());
|
174
|
-
}
|
175
|
-
drainQueueWhileRunning(runtimeFlags, lastTrace, cur0) {
|
715
|
+
drainQueueWhileRunning(cur0) {
|
176
716
|
let cur = cur0;
|
177
|
-
|
178
|
-
|
717
|
+
let message = this.inbox.dequeue(null);
|
718
|
+
while (message) {
|
179
719
|
switch (message._tag) {
|
180
720
|
case 0 /* FiberMessageTag.InterruptSignal */:
|
181
721
|
{
|
722
|
+
this.updateLastTrace(cur.trace);
|
182
723
|
this.processNewInterruptSignal(message.cause);
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
case 1 /* FiberMessageTag.GenStackTrace */:
|
187
|
-
{
|
188
|
-
const oldCur = cur;
|
189
|
-
cur = tsplus_module_4.flatMap(stackTrace => {
|
190
|
-
message.onTrace(stackTrace);
|
191
|
-
return oldCur;
|
192
|
-
}, undefined)(tsplus_module_4.stackTrace(undefined));
|
724
|
+
if (this.isInterruptible()) {
|
725
|
+
cur = tsplus_module_1.failCauseNow(message.cause, fileName_1 + ":850:46");
|
726
|
+
}
|
193
727
|
break;
|
194
728
|
}
|
195
|
-
case
|
729
|
+
case 1 /* FiberMessageTag.Stateful */:
|
196
730
|
{
|
197
|
-
message.onFiber
|
731
|
+
this.processStatefulMessage(message.onFiber);
|
198
732
|
break;
|
199
733
|
}
|
200
|
-
case
|
201
|
-
{
|
202
|
-
throw new tsplus_module_14.IllegalStateError("It is illegal to have multiple concurrent run loops in a single fiber");
|
203
|
-
}
|
204
|
-
case 4 /* FiberMessageTag.YieldNow */:
|
734
|
+
case 2 /* FiberMessageTag.Resume */:
|
205
735
|
{
|
206
|
-
|
207
|
-
cur = tsplus_module_4.flatMap(() => oldCur, undefined)(tsplus_module_4.yieldNow);
|
208
|
-
break;
|
736
|
+
throw new tsplus_module_27.IllegalStateError("It is illegal to have multiple concurrent run loops in a single fiber");
|
209
737
|
}
|
210
738
|
}
|
739
|
+
message = this.inbox.dequeue(null);
|
211
740
|
}
|
212
741
|
return cur;
|
213
742
|
}
|
214
|
-
|
743
|
+
ensureStackCapacity(size) {
|
744
|
+
const stack = this._stack;
|
745
|
+
const stackLength = stack.length;
|
746
|
+
if (stackLength < size) {
|
747
|
+
const newSize = (size & size - 1) == 0 ? size : highestOneBit(size) << 1;
|
748
|
+
const newStack = new Array(newSize);
|
749
|
+
copyArray(stack, 0, newStack, 0, stackLength);
|
750
|
+
this._stack = newStack;
|
751
|
+
}
|
752
|
+
}
|
753
|
+
evaluateEffect(initialDepth, effect0) {
|
215
754
|
// assert(this.running, "Invalid state in FiberRuntime: Fiber is not running");
|
216
|
-
this.
|
755
|
+
this._asyncContWith = null;
|
756
|
+
this._blockingOn = null;
|
757
|
+
this.updateLastTrace(effect0.trace);
|
758
|
+
const supervisor = this.getSupervisor();
|
759
|
+
supervisor.unsafeOnResume(this);
|
760
|
+
if (this._stack === null) {
|
761
|
+
this._stack = new Array(INITIAL_STACK_SIZE);
|
762
|
+
}
|
217
763
|
try {
|
218
|
-
let effect;
|
219
|
-
if (tsplus_module_9.interruptible(this._runtimeFlags) && this.isInterrupted()) {
|
220
|
-
effect = tsplus_module_4.failCause(() => this.getInterruptedCause(), fileName_1 + ":247:30");
|
221
|
-
} else {
|
222
|
-
effect = effect0;
|
223
|
-
}
|
764
|
+
let effect = effect0;
|
224
765
|
let finalExit = null;
|
225
766
|
while (effect !== null) {
|
226
767
|
try {
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
this.setExitValue(exit);
|
234
|
-
} else {
|
235
|
-
this.tell(tsplus_module_6.resume(tsplus_module_4.fromExitNow(exit, fileName_1 + ":265:59")));
|
236
|
-
}
|
768
|
+
if (this.shouldInterrupt()) {
|
769
|
+
effect = tsplus_module_1.failCause(() => this.getInterruptedCause(), fileName_1 + ":901:46");
|
770
|
+
}
|
771
|
+
const exit = this.runLoop(effect, 0, this._stackSize, initialDepth, 0);
|
772
|
+
if (exit === null) {
|
773
|
+
this._forksSinceYield = 0;
|
237
774
|
effect = null;
|
238
775
|
} else {
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
this.
|
246
|
-
this.tell(tsplus_module_6.resume(tsplus_module_4.unit));
|
247
|
-
effect = null;
|
776
|
+
this._runtimeFlags = tsplus_module_3.enable(this._runtimeFlags, 64 /* RuntimeFlag.WindDown */);
|
777
|
+
const interruption = this.interruptAllChildren();
|
778
|
+
if (interruption === null) {
|
779
|
+
if (this.inbox.isEmpty) {
|
780
|
+
finalExit = exit;
|
781
|
+
supervisor.unsafeOnEnd(finalExit, this);
|
782
|
+
this.setExitValue(exit);
|
248
783
|
} else {
|
249
|
-
|
784
|
+
this.tell(tsplus_module_16.resume(tsplus_module_1.fromExitNow(exit, fileName_1 + ":921:61")));
|
250
785
|
}
|
251
|
-
} else if (e._ioOpCode === 3 /* IOTag.Async */) {
|
252
786
|
effect = null;
|
253
787
|
} else {
|
254
|
-
|
788
|
+
effect = tsplus_module_1.flatMap(() => tsplus_module_1.fromExitNow(exit, fileName_1 + ":926:77"), this.id.location)(interruption);
|
255
789
|
}
|
790
|
+
}
|
791
|
+
} catch (t) {
|
792
|
+
if (this.isFatal(t)) {
|
793
|
+
// TODO
|
794
|
+
}
|
795
|
+
if ((0, _exceptions.isIOError)(t)) {
|
796
|
+
effect = tsplus_module_1.failCauseNow(t.cause, fileName_1 + ":935:49");
|
256
797
|
} else {
|
257
|
-
|
798
|
+
effect = tsplus_module_1.failCauseNow(tsplus_module_15.halt(t), fileName_1 + ":937:49");
|
258
799
|
}
|
259
800
|
}
|
260
801
|
}
|
802
|
+
return finalExit;
|
261
803
|
} finally {
|
804
|
+
this.gcStack();
|
262
805
|
this.getSupervisor().unsafeOnSuspend(this);
|
263
806
|
}
|
264
807
|
}
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
if ((this._runtimeFlags & 8 /* RuntimeFlag.OpSupervision */) !== 0) {
|
272
|
-
this.getSupervisor().unsafeOnEffect(this, cur);
|
273
|
-
}
|
274
|
-
const nextTrace = cur.trace;
|
275
|
-
if (nextTrace !== undefined) lastTrace = nextTrace;
|
276
|
-
cur = this.drainQueueWhileRunning(this._runtimeFlags, lastTrace, cur);
|
277
|
-
ops += 1;
|
278
|
-
if (ops > this.getFiberRef(tsplus_module_12.currentMaxFiberOps)) {
|
279
|
-
ops = 0;
|
280
|
-
const oldCur = cur;
|
281
|
-
const trace = lastTrace;
|
282
|
-
cur = tsplus_module_4.flatMap(() => oldCur, trace)(tsplus_module_4.yieldNow);
|
283
|
-
}
|
284
|
-
try {
|
285
|
-
switch (cur._ioOpCode) {
|
286
|
-
case 2 /* IOTag.Sync */:
|
287
|
-
{
|
288
|
-
const value = cur.i0();
|
289
|
-
const cont = this.getNextSuccessCont();
|
290
|
-
if (cont) {
|
291
|
-
switch (cont._ioOpCode) {
|
292
|
-
case 5 /* IOTag.OnSuccess */:
|
293
|
-
{
|
294
|
-
cur = cont.i1(value);
|
295
|
-
break;
|
296
|
-
}
|
297
|
-
case 4 /* IOTag.OnSuccessAndFailure */:
|
298
|
-
{
|
299
|
-
cur = cont.i2(value);
|
300
|
-
break;
|
301
|
-
}
|
302
|
-
case 11 /* IOTag.WhileLoop */:
|
303
|
-
{
|
304
|
-
cont.i2(value);
|
305
|
-
if (cont.i0()) {
|
306
|
-
this.stack.push(cont);
|
307
|
-
cur = cont.i1();
|
308
|
-
} else {
|
309
|
-
cur = tsplus_module_4.unit;
|
310
|
-
}
|
311
|
-
break;
|
312
|
-
}
|
313
|
-
case 14 /* IOTag.RevertFlags */:
|
314
|
-
{
|
315
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
316
|
-
if (tsplus_module_9.interruptible(this._runtimeFlags) && this.isInterrupted()) {
|
317
|
-
cur = tsplus_module_4.failCauseNow(this.getInterruptedCause(), fileName_1 + ":350:54");
|
318
|
-
} else {
|
319
|
-
cur = tsplus_module_4.succeedNow(value, fileName_1 + ":352:52");
|
320
|
-
}
|
321
|
-
break;
|
322
|
-
}
|
323
|
-
case 15 /* IOTag.UpdateTrace */:
|
324
|
-
{
|
325
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
326
|
-
cur = tsplus_module_4.unit;
|
327
|
-
break;
|
328
|
-
}
|
329
|
-
}
|
330
|
-
} else {
|
331
|
-
return tsplus_module_16.succeed(value, fileName_1 + ":363:34");
|
332
|
-
}
|
333
|
-
break;
|
334
|
-
}
|
335
|
-
case 4 /* IOTag.OnSuccessAndFailure */:
|
336
|
-
case 6 /* IOTag.OnFailure */:
|
337
|
-
case 5 /* IOTag.OnSuccess */:
|
338
|
-
{
|
339
|
-
this.stack.push(cur);
|
340
|
-
cur = cur.i0;
|
341
|
-
break;
|
342
|
-
}
|
343
|
-
case 3 /* IOTag.Async */:
|
344
|
-
{
|
345
|
-
this.asyncTrace = lastTrace;
|
346
|
-
this.asyncBlockinOn = cur.i1();
|
347
|
-
this.initiateAsync(this._runtimeFlags, cur.i0);
|
348
|
-
throw cur;
|
349
|
-
}
|
350
|
-
case 8 /* IOTag.UpdateRuntimeFlagsWithin */:
|
351
|
-
{
|
352
|
-
const updateFlags = cur.i0;
|
353
|
-
const oldRuntimeFlags = this._runtimeFlags;
|
354
|
-
const newRuntimeFlags = tsplus_module_10.patch(updateFlags, oldRuntimeFlags);
|
355
|
-
if (newRuntimeFlags === oldRuntimeFlags) {
|
356
|
-
cur = cur.i1(oldRuntimeFlags);
|
357
|
-
} else {
|
358
|
-
if (tsplus_module_9.interruptible(newRuntimeFlags) && this.isInterrupted()) {
|
359
|
-
cur = tsplus_module_4.failCauseNow(this.getInterruptedCause(), fileName_1 + ":389:50");
|
360
|
-
} else {
|
361
|
-
this.patchRuntimeFlags(this._runtimeFlags, updateFlags);
|
362
|
-
const revertFlags = tsplus_module_9.diff(newRuntimeFlags, oldRuntimeFlags);
|
363
|
-
this.stack.push(new RevertFlags(revertFlags));
|
364
|
-
cur = cur.i1(oldRuntimeFlags);
|
365
|
-
}
|
366
|
-
}
|
367
|
-
break;
|
368
|
-
}
|
369
|
-
case 9 /* IOTag.GenerateStackTrace */:
|
370
|
-
{
|
371
|
-
cur = tsplus_module_4.succeedNow(this.generateStackTrace(), fileName_1 + ":400:44");
|
372
|
-
break;
|
373
|
-
}
|
374
|
-
case 10 /* IOTag.Stateful */:
|
375
|
-
{
|
376
|
-
cur = cur.i0(this, new _FiberStatus.Running(this._runtimeFlags, lastTrace));
|
377
|
-
break;
|
378
|
-
}
|
379
|
-
case 0 /* IOTag.SucceedNow */:
|
380
|
-
{
|
381
|
-
const oldCur = cur;
|
382
|
-
const cont = this.getNextSuccessCont();
|
383
|
-
if (cont) {
|
384
|
-
switch (cont._ioOpCode) {
|
385
|
-
case 5 /* IOTag.OnSuccess */:
|
386
|
-
{
|
387
|
-
cur = cont.i1(oldCur.i0);
|
388
|
-
break;
|
389
|
-
}
|
390
|
-
case 4 /* IOTag.OnSuccessAndFailure */:
|
391
|
-
{
|
392
|
-
cur = cont.i2(oldCur.i0);
|
393
|
-
break;
|
394
|
-
}
|
395
|
-
case 11 /* IOTag.WhileLoop */:
|
396
|
-
{
|
397
|
-
cont.i2(oldCur.i0);
|
398
|
-
if (cont.i0()) {
|
399
|
-
this.stack.push(cont);
|
400
|
-
cur = cont.i1();
|
401
|
-
} else {
|
402
|
-
cur = tsplus_module_4.unit;
|
403
|
-
}
|
404
|
-
break;
|
405
|
-
}
|
406
|
-
case 14 /* IOTag.RevertFlags */:
|
407
|
-
{
|
408
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
409
|
-
if (tsplus_module_9.interruptible(this._runtimeFlags) && this.isInterrupted()) {
|
410
|
-
cur = tsplus_module_4.failCauseNow(this.getInterruptedCause(), fileName_1 + ":433:54");
|
411
|
-
}
|
412
|
-
break;
|
413
|
-
}
|
414
|
-
case 15 /* IOTag.UpdateTrace */:
|
415
|
-
{
|
416
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
417
|
-
cur = tsplus_module_4.unit;
|
418
|
-
break;
|
419
|
-
}
|
420
|
-
}
|
421
|
-
} else {
|
422
|
-
return tsplus_module_16.succeed(oldCur.i0, fileName_1 + ":444:34");
|
423
|
-
}
|
424
|
-
break;
|
425
|
-
}
|
426
|
-
case 1 /* IOTag.Fail */:
|
427
|
-
{
|
428
|
-
const cause = cur.i0();
|
429
|
-
const cont = this.getNextFailCont();
|
430
|
-
if (cont) {
|
431
|
-
switch (cont._ioOpCode) {
|
432
|
-
case 6 /* IOTag.OnFailure */:
|
433
|
-
case 4 /* IOTag.OnSuccessAndFailure */:
|
434
|
-
{
|
435
|
-
if (!(tsplus_module_9.interruptible(this._runtimeFlags) && this.isInterrupted())) {
|
436
|
-
cur = cont.i1(cause);
|
437
|
-
} else {
|
438
|
-
cur = tsplus_module_4.failCauseNow(tsplus_module_11.stripFailures(cause), fileName_1 + ":458:54");
|
439
|
-
}
|
440
|
-
break;
|
441
|
-
}
|
442
|
-
case 14 /* IOTag.RevertFlags */:
|
443
|
-
{
|
444
|
-
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
445
|
-
if (tsplus_module_9.interruptible(this._runtimeFlags) && this.isInterrupted()) {
|
446
|
-
const interruptedCause = this.getInterruptedCause();
|
447
|
-
if (tsplus_module_11.contains(interruptedCause)(cause)) {
|
448
|
-
cur = tsplus_module_4.failCauseNow(cause, fileName_1 + ":467:56");
|
449
|
-
} else {
|
450
|
-
cur = tsplus_module_4.failCauseNow(tsplus_module_11.sequential(cause, this.getInterruptedCause()), fileName_1 + ":469:56");
|
451
|
-
}
|
452
|
-
}
|
453
|
-
break;
|
454
|
-
}
|
455
|
-
case 15 /* IOTag.UpdateTrace */:
|
456
|
-
{
|
457
|
-
if (cont.trace !== undefined) lastTrace = cont.trace;
|
458
|
-
cur = tsplus_module_4.unit;
|
459
|
-
break;
|
460
|
-
}
|
461
|
-
}
|
462
|
-
} else {
|
463
|
-
return tsplus_module_16.failCause(cause, fileName_1 + ":481:36");
|
464
|
-
}
|
465
|
-
break;
|
466
|
-
}
|
467
|
-
case 7 /* IOTag.UpdateRuntimeFlags */:
|
468
|
-
{
|
469
|
-
this.patchRuntimeFlags(this._runtimeFlags, cur.i0);
|
470
|
-
cur = tsplus_module_4.unit;
|
471
|
-
break;
|
472
|
-
}
|
473
|
-
case 11 /* IOTag.WhileLoop */:
|
474
|
-
{
|
475
|
-
const iterate = cur;
|
476
|
-
const check = iterate.i0;
|
477
|
-
const body = iterate.i1;
|
478
|
-
if (check()) {
|
479
|
-
cur = body();
|
480
|
-
this.stack.push(iterate);
|
481
|
-
} else {
|
482
|
-
cur = tsplus_module_4.unit;
|
483
|
-
}
|
484
|
-
break;
|
485
|
-
}
|
486
|
-
case 12 /* IOTag.YieldNow */:
|
487
|
-
{
|
488
|
-
throw cur;
|
489
|
-
}
|
490
|
-
case 13 /* IOTag.Commit */:
|
491
|
-
{
|
492
|
-
cur = tsplus_module_17.atomically(cur, fileName_1 + ":506:34");
|
493
|
-
break;
|
494
|
-
}
|
495
|
-
case 16 /* IOTag.External */:
|
496
|
-
{
|
497
|
-
cur = cur.toIO;
|
498
|
-
break;
|
499
|
-
}
|
500
|
-
case null:
|
501
|
-
{
|
502
|
-
switch (cur._tag) {
|
503
|
-
case "Just" /* MaybeTag.Just */:
|
504
|
-
{
|
505
|
-
cur = tsplus_module_4.succeedNow(cur.value, fileName_1 + ":516:48");
|
506
|
-
break;
|
507
|
-
}
|
508
|
-
case "Nothing" /* MaybeTag.Nothing */:
|
509
|
-
{
|
510
|
-
cur = tsplus_module_4.failNow(new tsplus_module_14.NoSuchElementError(), fileName_1 + ":520:45");
|
511
|
-
break;
|
512
|
-
}
|
513
|
-
case "Left" /* EitherTag.Left */:
|
514
|
-
{
|
515
|
-
cur = tsplus_module_4.failNow(cur.left, fileName_1 + ":524:45");
|
516
|
-
break;
|
517
|
-
}
|
518
|
-
case "Right" /* EitherTag.Right */:
|
519
|
-
{
|
520
|
-
cur = tsplus_module_4.succeedNow(cur.right, fileName_1 + ":528:48");
|
521
|
-
break;
|
522
|
-
}
|
523
|
-
case "Failure" /* ExitTag.Failure */:
|
524
|
-
{
|
525
|
-
cur = tsplus_module_4.failCauseNow(cur.cause, fileName_1 + ":532:50");
|
526
|
-
break;
|
527
|
-
}
|
528
|
-
case "Success" /* ExitTag.Success */:
|
529
|
-
{
|
530
|
-
cur = tsplus_module_4.succeedNow(cur.value, fileName_1 + ":536:48");
|
531
|
-
break;
|
532
|
-
}
|
533
|
-
case "Tag":
|
534
|
-
{
|
535
|
-
cur = tsplus_module_18.service(cur, fileName_1 + ":540:45");
|
536
|
-
break;
|
537
|
-
}
|
538
|
-
}
|
539
|
-
}
|
808
|
+
evaluateMessageWhileSuspended(depth, fiberMessage) {
|
809
|
+
switch (fiberMessage._tag) {
|
810
|
+
case 0 /* FiberMessageTag.InterruptSignal */:
|
811
|
+
{
|
812
|
+
this.processNewInterruptSignal(fiberMessage.cause);
|
813
|
+
return 0 /* EvaluationSignal.Continue */;
|
540
814
|
}
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
815
|
+
case 1 /* FiberMessageTag.Stateful */:
|
816
|
+
{
|
817
|
+
this.processStatefulMessage(fiberMessage.onFiber);
|
818
|
+
return 0 /* EvaluationSignal.Continue */;
|
819
|
+
}
|
820
|
+
case 2 /* FiberMessageTag.Resume */:
|
821
|
+
{
|
822
|
+
const nextEffect = fiberMessage.cont;
|
823
|
+
const exit = this.evaluateEffect(depth, nextEffect);
|
824
|
+
if (exit === null) {
|
825
|
+
return 1 /* EvaluationSignal.YieldNow */;
|
826
|
+
}
|
827
|
+
return 0 /* EvaluationSignal.Continue */;
|
550
828
|
}
|
551
|
-
}
|
552
829
|
}
|
553
830
|
}
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
831
|
+
/**
|
832
|
+
* Removes references of entries from the stack higher than the current index
|
833
|
+
* so that they can be garbage collected.
|
834
|
+
*
|
835
|
+
* @note
|
836
|
+
* We only GC up to the {@link STACK_IDX_GC_THRESHOLD} index because
|
837
|
+
* we know that entries in indices higher than that have been auto-gc'd
|
838
|
+
* during the runloop
|
839
|
+
* @note
|
840
|
+
* This method MUST be invoked by the fiber itself while it's still running.
|
841
|
+
*/
|
842
|
+
gcStack() {
|
843
|
+
const fromIndex = this._stackSize;
|
844
|
+
if (fromIndex === 0) {
|
845
|
+
this._stack = null;
|
846
|
+
} else {
|
847
|
+
const stack = this._stack;
|
848
|
+
const toIndex = Math.min(STACK_IDX_GC_THRESHOLD, stack.length);
|
849
|
+
if (fromIndex < toIndex && stack[fromIndex] !== null) {
|
850
|
+
stack.fill(null, fromIndex, toIndex);
|
851
|
+
}
|
563
852
|
}
|
564
|
-
return tsplus_module_24.initial(fiberRef);
|
565
853
|
}
|
566
|
-
|
567
|
-
this.
|
568
|
-
|
569
|
-
|
570
|
-
this.
|
854
|
+
getStatus() {
|
855
|
+
if (this._exitValue !== null) {
|
856
|
+
return tsplus_module_25.done;
|
857
|
+
} else {
|
858
|
+
if (this._asyncContWith !== null) {
|
859
|
+
return tsplus_module_25.suspended(this._runtimeFlags, this._blockingOn ?? tsplus_module_33.none, this._lastTrace);
|
860
|
+
} else {
|
861
|
+
return tsplus_module_25.running(this._runtimeFlags, this._lastTrace);
|
862
|
+
}
|
571
863
|
}
|
572
864
|
}
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
865
|
+
initiateAsync(asyncRegister) {
|
866
|
+
let alreadyCalled = false;
|
867
|
+
const callback = effect => {
|
868
|
+
if (!alreadyCalled) {
|
869
|
+
alreadyCalled = true;
|
870
|
+
this.tell(tsplus_module_16.resume(effect));
|
871
|
+
}
|
872
|
+
};
|
873
|
+
if (this.isInterruptible()) {
|
874
|
+
this._asyncContWith = callback;
|
875
|
+
} else {
|
876
|
+
this._asyncContWith = () => void 0;
|
582
877
|
}
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
return newRuntimeFlags;
|
595
|
-
}
|
596
|
-
sendInterruptSignalToAllChildren() {
|
597
|
-
if (this._children === null || this._children.size === 0) return false;else {
|
598
|
-
let told = false;
|
599
|
-
for (const child of this._children) {
|
600
|
-
if (child !== null) {
|
601
|
-
child.tell(tsplus_module_6.interruptSignal(tsplus_module_11.interrupt(this.id)));
|
602
|
-
told = true;
|
878
|
+
try {
|
879
|
+
const sync = asyncRegister(callback);
|
880
|
+
if (sync != null) {
|
881
|
+
if (!alreadyCalled) {
|
882
|
+
alreadyCalled = true;
|
883
|
+
this._asyncContWith = null;
|
884
|
+
this._blockingOn = null;
|
885
|
+
return sync;
|
886
|
+
} else {
|
887
|
+
this.log(() => "Async operation attempted synchronous resumption, but its callback was already invoked; synchronous value will be discarded", tsplus_module_15.empty(), tsplus_module_5.just(tsplus_module_19.Error, fileName_1 + ":1039:17"), this.id.location);
|
888
|
+
return null;
|
603
889
|
}
|
890
|
+
} else {
|
891
|
+
return null;
|
604
892
|
}
|
605
|
-
|
893
|
+
} catch (t) {
|
894
|
+
callback(tsplus_module_1.failCauseNow(tsplus_module_15.halt(t), fileName_1 + ":1049:31"));
|
895
|
+
return null;
|
606
896
|
}
|
607
897
|
}
|
608
898
|
interruptAllChildren() {
|
@@ -618,10 +908,10 @@ class FiberRuntime {
|
|
618
908
|
if (value != null && !value.done) {
|
619
909
|
return value.value.await;
|
620
910
|
} else {
|
621
|
-
return
|
911
|
+
return tsplus_module_1.unit;
|
622
912
|
}
|
623
913
|
};
|
624
|
-
const io = new _definition4.IOPrimitive(
|
914
|
+
const io = new _definition4.IOPrimitive(9 /* IOTag.WhileLoop */);
|
625
915
|
io.i0 = check;
|
626
916
|
io.i1 = body;
|
627
917
|
io.i2 = () => {
|
@@ -632,171 +922,124 @@ class FiberRuntime {
|
|
632
922
|
return null;
|
633
923
|
}
|
634
924
|
}
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
925
|
+
isInterruptible() {
|
926
|
+
return tsplus_module_3.interruptible(this._runtimeFlags);
|
927
|
+
}
|
928
|
+
patchRuntimeFlags(patch, cause, continueEffect) {
|
929
|
+
const changed = this.patchRuntimeFlagsOnly(patch);
|
930
|
+
const interruptEnabled = tsplus_module_4.isEnabledPatch(patch, 1 /* RuntimeFlag.Interruption */);
|
931
|
+
if (changed && interruptEnabled && this.shouldInterrupt()) {
|
932
|
+
if (cause !== null) {
|
933
|
+
return tsplus_module_1.failCauseNow(tsplus_module_15.sequential(cause, this.getInterruptedCause()), fileName_1 + ":1103:43");
|
934
|
+
} else {
|
935
|
+
return tsplus_module_1.failCauseNow(this.getInterruptedCause(), fileName_1 + ":1105:43");
|
641
936
|
}
|
642
|
-
}
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
} catch (e) {
|
647
|
-
callback(tsplus_module_4.failCauseNow(tsplus_module_11.halt(e), fileName_1 + ":681:31"));
|
937
|
+
} else if (cause !== null) {
|
938
|
+
return tsplus_module_1.failCauseNow(cause, fileName_1 + ":1108:41");
|
939
|
+
} else {
|
940
|
+
return continueEffect;
|
648
941
|
}
|
649
942
|
}
|
650
|
-
|
651
|
-
|
943
|
+
patchRuntimeFlagsOnly(patch) {
|
944
|
+
const oldFlags = this._runtimeFlags;
|
945
|
+
const newFlags = tsplus_module_4.patch(patch, oldFlags);
|
946
|
+
const changed = oldFlags !== newFlags;
|
947
|
+
if (changed) {
|
948
|
+
if (tsplus_module_4.isEnabledPatch(patch, 2 /* RuntimeFlag.CurrentFiber */)) {
|
949
|
+
// TODO
|
950
|
+
} else {
|
951
|
+
// TODO
|
952
|
+
}
|
953
|
+
this._runtimeFlags = newFlags;
|
954
|
+
}
|
955
|
+
return changed;
|
652
956
|
}
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
957
|
+
/**
|
958
|
+
* Sets the `_stackSize` to `nextStackIndex`.
|
959
|
+
*
|
960
|
+
* This method might also null out the entry in the stack to allow it to be
|
961
|
+
* GC'd, but only if the index is >= `FiberRuntime.StackIdxGcThreshold`.
|
962
|
+
*
|
963
|
+
* This is based on the assumption that when the stack is shallow, the entries
|
964
|
+
* in the array will keep being overwritten as the pointer moves up and down.
|
965
|
+
*/
|
966
|
+
popStackFrame(nextStackIndex) {
|
967
|
+
if (nextStackIndex >= STACK_IDX_GC_THRESHOLD) {
|
968
|
+
this._stack[nextStackIndex] = null;
|
657
969
|
}
|
658
|
-
this.
|
970
|
+
this._stackSize = nextStackIndex;
|
659
971
|
}
|
660
972
|
processNewInterruptSignal(cause) {
|
661
973
|
this.addInterruptedCause(cause);
|
662
974
|
this.sendInterruptSignalToAllChildren();
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
case 0 /* FiberMessageTag.InterruptSignal */:
|
667
|
-
{
|
668
|
-
this.processNewInterruptSignal(fiberMessage.cause);
|
669
|
-
if (this.asyncInterruptor !== null) {
|
670
|
-
this.asyncInterruptor(tsplus_module_4.failCause(() => fiberMessage.cause, fileName_1 + ":708:45"));
|
671
|
-
this.asyncInterruptor = null;
|
672
|
-
}
|
673
|
-
return 0 /* EvaluationSignal.Continue */;
|
674
|
-
}
|
675
|
-
case 1 /* FiberMessageTag.GenStackTrace */:
|
676
|
-
{
|
677
|
-
fiberMessage.onTrace(this.generateStackTrace());
|
678
|
-
return 0 /* EvaluationSignal.Continue */;
|
679
|
-
}
|
680
|
-
case 2 /* FiberMessageTag.Stateful */:
|
681
|
-
{
|
682
|
-
let status;
|
683
|
-
if (this._exitValue !== null) {
|
684
|
-
status = new _FiberStatus.Done();
|
685
|
-
} else if (this.asyncTrace === null) {
|
686
|
-
status = new _FiberStatus.Running(this._runtimeFlags, null);
|
687
|
-
} else {
|
688
|
-
status = new _FiberStatus.Suspended(this._runtimeFlags, this.asyncBlockinOn, this.asyncTrace);
|
689
|
-
}
|
690
|
-
fiberMessage.onFiber(this, status);
|
691
|
-
return 0 /* EvaluationSignal.Continue */;
|
692
|
-
}
|
693
|
-
case 3 /* FiberMessageTag.Resume */:
|
694
|
-
{
|
695
|
-
this.asyncInterruptor = null;
|
696
|
-
this.asyncTrace = null;
|
697
|
-
this.asyncBlockinOn = null;
|
698
|
-
this.evaluateEffect(fiberMessage.cont);
|
699
|
-
return 0 /* EvaluationSignal.Continue */;
|
700
|
-
}
|
701
|
-
case 4 /* FiberMessageTag.YieldNow */:
|
702
|
-
{
|
703
|
-
return 1 /* EvaluationSignal.YieldNow */;
|
704
|
-
}
|
975
|
+
const k = this._asyncContWith;
|
976
|
+
if (k !== null) {
|
977
|
+
k(tsplus_module_1.failCauseNow(cause, fileName_1 + ":1154:24"));
|
705
978
|
}
|
706
979
|
}
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
980
|
+
processStatefulMessage(onFiber) {
|
981
|
+
try {
|
982
|
+
onFiber(this);
|
983
|
+
} catch (t) {
|
984
|
+
if (this.isFatal(t)) {
|
985
|
+
// TODO
|
986
|
+
} else {
|
987
|
+
this.log(() => `An unexpected error was encountered while processing stateful fiber message with callback ${onFiber}`, tsplus_module_15.halt(t), tsplus_module_5.just(tsplus_module_19.Error, fileName_1 + ":1168:15"), this.id.location);
|
988
|
+
}
|
712
989
|
}
|
713
|
-
return new _Trace.Trace(this.fiberId, builder.result());
|
714
990
|
}
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
991
|
+
pushStackFrame(k, stackIndex) {
|
992
|
+
const newSize = stackIndex + 1;
|
993
|
+
this.ensureStackCapacity(newSize);
|
994
|
+
this._stack[stackIndex] = k;
|
995
|
+
this._stackSize = newSize;
|
996
|
+
return newSize;
|
721
997
|
}
|
722
|
-
|
723
|
-
this.
|
998
|
+
run() {
|
999
|
+
this.drainQueueOnCurrentThread(0);
|
724
1000
|
}
|
725
|
-
|
726
|
-
if (
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
if (!this.queue.isEmpty) {
|
733
|
-
this.drainQueueLaterOnExecutor();
|
1001
|
+
sendInterruptSignalToAllChildren() {
|
1002
|
+
if (this._children === null || this._children.size === 0) return false;else {
|
1003
|
+
let told = false;
|
1004
|
+
for (const child of this._children) {
|
1005
|
+
if (child !== null) {
|
1006
|
+
child.tell(tsplus_module_16.interruptSignal(tsplus_module_15.interrupt(this.id)));
|
1007
|
+
told = true;
|
734
1008
|
}
|
735
1009
|
}
|
736
|
-
|
737
|
-
this.tell(tsplus_module_6.resume(effect));
|
1010
|
+
return told;
|
738
1011
|
}
|
739
1012
|
}
|
740
|
-
|
741
|
-
this.
|
742
|
-
|
743
|
-
|
744
|
-
this.setFiberRef(fiberRef, f(this.getFiberRef(fiberRef)));
|
745
|
-
}
|
746
|
-
removeObserver(observer) {
|
747
|
-
this.observers = tsplus_module_25.filter(f => f !== observer)(this.observers);
|
748
|
-
}
|
749
|
-
addChild(child) {
|
750
|
-
this.getChildren().add(child);
|
751
|
-
}
|
752
|
-
removeChild(child) {
|
753
|
-
if (this._children !== null) {
|
754
|
-
this._children.delete(child);
|
1013
|
+
setExitValue(exit) {
|
1014
|
+
this._exitValue = exit;
|
1015
|
+
for (const observer of this.observers) {
|
1016
|
+
observer(exit);
|
755
1017
|
}
|
1018
|
+
this.observers = tsplus_module_7.empty();
|
756
1019
|
}
|
757
|
-
|
758
|
-
return
|
759
|
-
}
|
760
|
-
log(message, cause, overrideLogLevel, trace) {
|
761
|
-
const logLevel = tsplus_module_27.getOrElse(() => this.getFiberRef(tsplus_module_12.currentLogLevel))(overrideLogLevel);
|
762
|
-
const spans = this.getFiberRef(tsplus_module_12.currentLogSpan);
|
763
|
-
const annotations = this.getFiberRef(tsplus_module_12.currentLogAnnotations);
|
764
|
-
const contextMap = this.getFiberRefs();
|
765
|
-
tsplus_module_30.filterLogLevel(level => tsplus_module_28.gte(tsplus_module_28.Info)(level))(tsplus_module_30.map(s => console.log(s))(tsplus_module_29.defaultString)).log(tsplus_module_20.parse(trace), this.fiberId, logLevel, message, cause, contextMap, spans, annotations);
|
766
|
-
}
|
767
|
-
deleteFiberRef(ref) {
|
768
|
-
this._fiberRefs = tsplus_module_8.remove(this._fiberRefs, ref);
|
769
|
-
}
|
770
|
-
get status() {
|
771
|
-
return this.ask((_, status) => status);
|
772
|
-
}
|
773
|
-
get trace() {
|
774
|
-
return tsplus_module_4.defer(() => {
|
775
|
-
const future = tsplus_module_3.unsafeMake(this.fiberId);
|
776
|
-
this.tell(tsplus_module_6.genStackTrace(trace => tsplus_module_5.unsafeDone(tsplus_module_4.succeedNow(trace, fileName_1 + ":845:86"), fileName_1 + ":845:72")(future)));
|
777
|
-
return tsplus_module_5.wait(future, fileName_1 + ":846:20");
|
778
|
-
}, fileName_1 + ":843:20");
|
779
|
-
}
|
780
|
-
getNextSuccessCont() {
|
781
|
-
while (this.stack.hasNext) {
|
782
|
-
const frame = this.stack.pop();
|
783
|
-
if (frame._ioOpCode !== 6 /* IOTag.OnFailure */) {
|
784
|
-
return frame;
|
785
|
-
}
|
786
|
-
}
|
1020
|
+
shouldInterrupt() {
|
1021
|
+
return this.isInterruptible() && this.isInterrupted();
|
787
1022
|
}
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
if (frame._ioOpCode !== 5 /* IOTag.OnSuccess */ && frame._ioOpCode !== 11 /* IOTag.WhileLoop */) {
|
792
|
-
return frame;
|
793
|
-
}
|
1023
|
+
updateLastTrace(newTrace) {
|
1024
|
+
if (newTrace !== null && newTrace !== "" && this._lastTrace !== newTrace) {
|
1025
|
+
this._lastTrace = newTrace;
|
794
1026
|
}
|
795
1027
|
}
|
796
|
-
isFatal(t) {
|
797
|
-
return this.getFiberRef(tsplus_module_12.currentIsFatal).apply(t);
|
798
|
-
}
|
799
1028
|
}
|
800
1029
|
exports.FiberRuntime = FiberRuntime;
|
801
1030
|
_a = _definition3.FiberTypeId;
|
1031
|
+
function highestOneBit(i) {
|
1032
|
+
i |= i >> 1;
|
1033
|
+
i |= i >> 2;
|
1034
|
+
i |= i >> 4;
|
1035
|
+
i |= i >> 8;
|
1036
|
+
i |= i >> 16;
|
1037
|
+
return i - (i >>> 1);
|
1038
|
+
}
|
1039
|
+
function copyArray(source, sourcePos, dest, destPos, length) {
|
1040
|
+
const j = Math.min(source.length, sourcePos + length);
|
1041
|
+
for (let i = sourcePos; i < j; i++) {
|
1042
|
+
dest[destPos + i - sourcePos] = source[i];
|
1043
|
+
}
|
1044
|
+
}
|
802
1045
|
//# sourceMappingURL=FiberRuntime.cjs.map
|