@fncts/io 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- package/Cached/definition.d.ts +6 -4
- package/Cached/internal.d.ts +4 -4
- package/Channel/api.d.ts +4 -4
- package/Channel/definition.d.ts +35 -14
- package/Channel/internal/ChannelExecutor.d.ts +1 -0
- package/Channel/internal/MergeDecision.d.ts +10 -6
- package/CountdownLatch.d.ts +1 -1
- package/Differ/definition.d.ts +2 -4
- package/Fiber/FiberRuntime.d.ts +9 -11
- package/Fiber/definition.d.ts +12 -6
- package/FiberRef/definition.d.ts +6 -2
- package/FiberRefs/api.d.ts +1 -1
- package/FiberRefs/definition.d.ts +1 -1
- package/Hub/definition.d.ts +29 -15
- package/IO/api/interrupt.d.ts +19 -19
- package/IO/api/onTermination.d.ts +0 -1
- package/IO/api/sequenceT.d.ts +19 -3
- package/IO/api.d.ts +17 -1
- package/IO/definition.d.ts +40 -26
- package/IO.d.ts +0 -1
- package/Layer/definition.d.ts +17 -13
- package/Logger/definition.d.ts +10 -6
- package/MVar/api.d.ts +101 -0
- package/MVar/definition.d.ts +43 -0
- package/MVar.d.ts +2 -0
- package/Push/api.d.ts +7 -4
- package/Push/definition.d.ts +10 -3
- package/Push/internal.d.ts +1 -1
- package/Queue/api/dimapIO.d.ts +17 -13
- package/Queue/definition.d.ts +26 -18
- package/Ref/Derived.d.ts +3 -1
- package/Ref/Synchronized/constructors.d.ts +6 -1
- package/Ref/Synchronized/definition.d.ts +4 -2
- package/Ref/definition.d.ts +36 -25
- package/Ref.d.ts +0 -1
- package/RefSubject/definition.d.ts +17 -11
- package/Reloadable/definition.d.ts +5 -1
- package/STM/api/atomically.d.ts +9 -0
- package/STM/api.d.ts +12 -6
- package/STM/definition.d.ts +28 -15
- package/STM/internal/Entry.d.ts +2 -2
- package/STM/internal/TryCommit.d.ts +2 -2
- package/STM/internal/Versioned.d.ts +1 -1
- package/STM.d.ts +1 -0
- package/Schedule/definition.d.ts +7 -3
- package/Scope/definition.d.ts +1 -1
- package/ScopedRef/definition.d.ts +1 -1
- package/State/api.d.ts +1 -1
- package/State/definition.d.ts +5 -2
- package/State/internal.d.ts +6 -2
- package/Stream/definition.d.ts +26 -5
- package/Stream/internal/Handoff.d.ts +21 -15
- package/Stream/internal/SinkEndReason.d.ts +2 -2
- package/Subject/Atomic.d.ts +8 -4
- package/SupervisorPatch.d.ts +1 -1
- package/TExit/definition.d.ts +5 -5
- package/TRef/definition.d.ts +16 -14
- package/TRef.d.ts +0 -1
- package/_cjs/Cached/definition.cjs +4 -2
- package/_cjs/Cached/definition.cjs.map +1 -1
- package/_cjs/Cached/internal.cjs +7 -6
- package/_cjs/Cached/internal.cjs.map +1 -1
- package/_cjs/Channel/api/mapOutConcurrentIO.cjs +1 -1
- package/_cjs/Channel/api/mergeAllWith.cjs +1 -1
- package/_cjs/Channel/api.cjs +20 -20
- package/_cjs/Channel/api.cjs.map +1 -1
- package/_cjs/Channel/definition.cjs +13 -3
- package/_cjs/Channel/definition.cjs.map +1 -1
- package/_cjs/Channel/internal/ChannelExecutor.cjs +11 -6
- package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
- package/_cjs/Channel/internal/MergeDecision.cjs +7 -3
- package/_cjs/Channel/internal/MergeDecision.cjs.map +1 -1
- package/_cjs/CountdownLatch.cjs +4 -2
- package/_cjs/CountdownLatch.cjs.map +1 -1
- package/_cjs/Differ/definition.cjs +3 -1
- package/_cjs/Differ/definition.cjs.map +1 -1
- package/_cjs/Fiber/FiberRuntime.cjs +96 -89
- package/_cjs/Fiber/FiberRuntime.cjs.map +1 -1
- package/_cjs/Fiber/definition.cjs +8 -4
- package/_cjs/Fiber/definition.cjs.map +1 -1
- package/_cjs/FiberRef/definition.cjs +8 -4
- package/_cjs/FiberRef/definition.cjs.map +1 -1
- package/_cjs/Future/api.cjs +17 -6
- package/_cjs/Future/api.cjs.map +1 -1
- package/_cjs/Hub/api.cjs +5 -5
- package/_cjs/Hub/api.cjs.map +1 -1
- package/_cjs/Hub/definition.cjs +9 -7
- package/_cjs/Hub/definition.cjs.map +1 -1
- package/_cjs/Hub/internal.cjs +6 -6
- package/_cjs/Hub/internal.cjs.map +1 -1
- package/_cjs/IO/api/asyncIO.cjs +1 -1
- package/_cjs/IO/api/asyncIO.cjs.map +1 -1
- package/_cjs/IO/api/asyncInterrupt.cjs +2 -2
- package/_cjs/IO/api/asyncInterrupt.cjs.map +1 -1
- package/_cjs/IO/api/bracketExit.cjs +1 -1
- package/_cjs/IO/api/bracketExit.cjs.map +1 -1
- package/_cjs/IO/api/foreachConcurrent.cjs +2 -2
- package/_cjs/IO/api/foreachConcurrent.cjs.map +1 -1
- package/_cjs/IO/api/forkIn.cjs +1 -1
- package/_cjs/IO/api/forkIn.cjs.map +1 -1
- package/_cjs/IO/api/forkScoped.cjs +1 -1
- package/_cjs/IO/api/forkScoped.cjs.map +1 -1
- package/_cjs/IO/api/fulfill.cjs +1 -1
- package/_cjs/IO/api/fulfill.cjs.map +1 -1
- package/_cjs/IO/api/interrupt.cjs +52 -43
- package/_cjs/IO/api/interrupt.cjs.map +1 -1
- package/_cjs/IO/api/onTermination.cjs +7 -6
- package/_cjs/IO/api/onTermination.cjs.map +1 -1
- package/_cjs/IO/api/race.cjs +1 -1
- package/_cjs/IO/api/race.cjs.map +1 -1
- package/_cjs/IO/api/sequenceT.cjs +1 -1
- package/_cjs/IO/api/sequenceT.cjs.map +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs +1 -1
- package/_cjs/IO/api/zipConcurrent.cjs.map +1 -1
- package/_cjs/IO/api.cjs +79 -53
- package/_cjs/IO/api.cjs.map +1 -1
- package/_cjs/IO/definition.cjs +26 -21
- package/_cjs/IO/definition.cjs.map +1 -1
- package/_cjs/IO.cjs +0 -11
- package/_cjs/IO.cjs.map +1 -1
- package/_cjs/Layer/MemoMap.cjs +30 -31
- package/_cjs/Layer/MemoMap.cjs.map +1 -1
- package/_cjs/Layer/api.cjs +1 -1
- package/_cjs/Layer/api.cjs.map +1 -1
- package/_cjs/Layer/definition.cjs +12 -10
- package/_cjs/Layer/definition.cjs.map +1 -1
- package/_cjs/Logger/definition.cjs +3 -1
- package/_cjs/Logger/definition.cjs.map +1 -1
- package/_cjs/MVar/api.cjs +170 -0
- package/_cjs/MVar/api.cjs.map +1 -0
- package/_cjs/MVar/definition.cjs +28 -0
- package/_cjs/MVar/definition.cjs.map +1 -0
- package/_cjs/MVar.cjs +28 -0
- package/_cjs/MVar.cjs.map +1 -0
- package/_cjs/Push/api.cjs +39 -36
- package/_cjs/Push/api.cjs.map +1 -1
- package/_cjs/Push/definition.cjs +9 -2
- package/_cjs/Push/definition.cjs.map +1 -1
- package/_cjs/Push/internal.cjs +4 -2
- package/_cjs/Push/internal.cjs.map +1 -1
- package/_cjs/Queue/api/dimapIO.cjs +10 -10
- package/_cjs/Queue/api/dimapIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterInputIO.cjs +4 -4
- package/_cjs/Queue/api/filterInputIO.cjs.map +1 -1
- package/_cjs/Queue/api/filterOutputIO.cjs +7 -7
- package/_cjs/Queue/api/filterOutputIO.cjs.map +1 -1
- package/_cjs/Queue/definition.cjs +3 -1
- package/_cjs/Queue/definition.cjs.map +1 -1
- package/_cjs/Queue/internal.cjs +2 -2
- package/_cjs/Queue/internal.cjs.map +1 -1
- package/_cjs/Queue/strategy.cjs +2 -2
- package/_cjs/Queue/strategy.cjs.map +1 -1
- package/_cjs/Ref/Derived.cjs +8 -4
- package/_cjs/Ref/Derived.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/constructors.cjs +16 -7
- package/_cjs/Ref/Synchronized/constructors.cjs.map +1 -1
- package/_cjs/Ref/Synchronized/definition.cjs +16 -12
- package/_cjs/Ref/Synchronized/definition.cjs.map +1 -1
- package/_cjs/Ref/definition.cjs +3 -2
- package/_cjs/Ref/definition.cjs.map +1 -1
- package/_cjs/Ref.cjs +0 -11
- package/_cjs/Ref.cjs.map +1 -1
- package/_cjs/RefSubject/Synchronized/api.cjs +1 -1
- package/_cjs/RefSubject/definition.cjs +9 -5
- package/_cjs/RefSubject/definition.cjs.map +1 -1
- package/_cjs/Reloadable/definition.cjs +4 -2
- package/_cjs/Reloadable/definition.cjs.map +1 -1
- package/_cjs/STM/api/atomically.cjs +55 -0
- package/_cjs/STM/api/atomically.cjs.map +1 -0
- package/_cjs/STM/api.cjs +65 -91
- package/_cjs/STM/api.cjs.map +1 -1
- package/_cjs/STM/definition.cjs +32 -19
- package/_cjs/STM/definition.cjs.map +1 -1
- package/_cjs/STM/driver.cjs +3 -3
- package/_cjs/STM/driver.cjs.map +1 -1
- package/_cjs/STM/internal/Entry.cjs +6 -3
- package/_cjs/STM/internal/Entry.cjs.map +1 -1
- package/_cjs/STM/internal/TryCommit.cjs +5 -2
- package/_cjs/STM/internal/TryCommit.cjs.map +1 -1
- package/_cjs/STM/internal/Versioned.cjs +3 -1
- package/_cjs/STM/internal/Versioned.cjs.map +1 -1
- package/_cjs/STM.cjs +11 -0
- package/_cjs/STM.cjs.map +1 -1
- package/_cjs/Schedule/definition.cjs +3 -1
- package/_cjs/Schedule/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 +5 -3
- package/_cjs/Scope/definition.cjs.map +1 -1
- package/_cjs/ScopedRef/api.cjs +2 -2
- package/_cjs/ScopedRef/api.cjs.map +1 -1
- package/_cjs/ScopedRef/definition.cjs +3 -1
- package/_cjs/ScopedRef/definition.cjs.map +1 -1
- package/_cjs/State/api.cjs +2 -2
- package/_cjs/State/api.cjs.map +1 -1
- package/_cjs/State/definition.cjs +4 -2
- package/_cjs/State/definition.cjs.map +1 -1
- package/_cjs/State/internal.cjs +7 -3
- package/_cjs/State/internal.cjs.map +1 -1
- package/_cjs/Stream/api.cjs +1 -1
- package/_cjs/Stream/definition.cjs +4 -2
- package/_cjs/Stream/definition.cjs.map +1 -1
- package/_cjs/Stream/internal/Handoff.cjs +37 -37
- package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
- package/_cjs/Stream/internal/SinkEndReason.cjs +6 -3
- package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -1
- package/_cjs/Subject/Atomic.cjs +6 -4
- package/_cjs/Subject/Atomic.cjs.map +1 -1
- package/_cjs/SubscriptionRef.cjs +1 -1
- package/_cjs/SupervisorPatch.cjs +3 -1
- package/_cjs/SupervisorPatch.cjs.map +1 -1
- package/_cjs/TExit/definition.cjs +25 -24
- package/_cjs/TExit/definition.cjs.map +1 -1
- package/_cjs/TFuture/constructors.cjs +1 -1
- package/_cjs/TReentrantLock/api.cjs +10 -9
- package/_cjs/TReentrantLock/api.cjs.map +1 -1
- package/_cjs/TRef/constructors.cjs +1 -1
- package/_cjs/TRef/definition.cjs +21 -21
- package/_cjs/TRef/definition.cjs.map +1 -1
- package/_cjs/TRef.cjs +0 -11
- package/_cjs/TRef.cjs.map +1 -1
- package/_cjs/TSemaphore/api.cjs +2 -2
- package/_cjs/TSemaphore/api.cjs.map +1 -1
- package/_cjs/TSemaphore/constructors.cjs +1 -1
- package/_cjs/internal/IsFatal.cjs +3 -1
- package/_cjs/internal/IsFatal.cjs.map +1 -1
- package/_mjs/Cached/definition.mjs +4 -2
- package/_mjs/Cached/definition.mjs.map +1 -1
- package/_mjs/Cached/internal.mjs +3 -5
- package/_mjs/Cached/internal.mjs.map +1 -1
- package/_mjs/Channel/api/mapOutConcurrentIO.mjs +1 -1
- package/_mjs/Channel/api/mergeAllWith.mjs +1 -1
- package/_mjs/Channel/api.mjs +15 -14
- package/_mjs/Channel/api.mjs.map +1 -1
- package/_mjs/Channel/definition.mjs +9 -1
- package/_mjs/Channel/definition.mjs.map +1 -1
- package/_mjs/Channel/internal/ChannelExecutor.mjs +11 -6
- package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
- package/_mjs/Channel/internal/MergeDecision.mjs +4 -1
- package/_mjs/Channel/internal/MergeDecision.mjs.map +1 -1
- package/_mjs/CountdownLatch.mjs +3 -1
- package/_mjs/CountdownLatch.mjs.map +1 -1
- package/_mjs/Differ/definition.mjs +3 -1
- package/_mjs/Differ/definition.mjs.map +1 -1
- package/_mjs/Fiber/FiberRuntime.mjs +97 -90
- package/_mjs/Fiber/FiberRuntime.mjs.map +1 -1
- package/_mjs/Fiber/definition.mjs +5 -2
- package/_mjs/Fiber/definition.mjs.map +1 -1
- package/_mjs/FiberRef/definition.mjs +6 -3
- package/_mjs/FiberRef/definition.mjs.map +1 -1
- package/_mjs/Future/api.mjs +17 -6
- package/_mjs/Future/api.mjs.map +1 -1
- package/_mjs/Hub/api.mjs +6 -6
- package/_mjs/Hub/api.mjs.map +1 -1
- package/_mjs/Hub/definition.mjs +5 -4
- package/_mjs/Hub/definition.mjs.map +1 -1
- package/_mjs/Hub/internal.mjs +6 -6
- package/_mjs/Hub/internal.mjs.map +1 -1
- package/_mjs/IO/api/asyncIO.mjs +1 -1
- package/_mjs/IO/api/asyncIO.mjs.map +1 -1
- package/_mjs/IO/api/asyncInterrupt.mjs +2 -2
- package/_mjs/IO/api/asyncInterrupt.mjs.map +1 -1
- package/_mjs/IO/api/bracketExit.mjs +1 -1
- package/_mjs/IO/api/bracketExit.mjs.map +1 -1
- package/_mjs/IO/api/foreachConcurrent.mjs +2 -2
- package/_mjs/IO/api/foreachConcurrent.mjs.map +1 -1
- package/_mjs/IO/api/forkIn.mjs +1 -1
- package/_mjs/IO/api/forkIn.mjs.map +1 -1
- package/_mjs/IO/api/forkScoped.mjs +1 -1
- package/_mjs/IO/api/forkScoped.mjs.map +1 -1
- package/_mjs/IO/api/fulfill.mjs +1 -1
- package/_mjs/IO/api/fulfill.mjs.map +1 -1
- package/_mjs/IO/api/interrupt.mjs +46 -38
- package/_mjs/IO/api/interrupt.mjs.map +1 -1
- package/_mjs/IO/api/onTermination.mjs +7 -6
- 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/sequenceT.mjs +1 -1
- package/_mjs/IO/api/sequenceT.mjs.map +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs +1 -1
- package/_mjs/IO/api/zipConcurrent.mjs.map +1 -1
- package/_mjs/IO/api.mjs +73 -50
- package/_mjs/IO/api.mjs.map +1 -1
- package/_mjs/IO/definition.mjs +23 -19
- package/_mjs/IO/definition.mjs.map +1 -1
- package/_mjs/IO.mjs +0 -1
- package/_mjs/IO.mjs.map +1 -1
- package/_mjs/Layer/MemoMap.mjs +28 -29
- package/_mjs/Layer/MemoMap.mjs.map +1 -1
- package/_mjs/Layer/api.mjs +2 -2
- package/_mjs/Layer/api.mjs.map +1 -1
- package/_mjs/Layer/definition.mjs +9 -8
- package/_mjs/Layer/definition.mjs.map +1 -1
- package/_mjs/Logger/definition.mjs +1 -0
- package/_mjs/Logger/definition.mjs.map +1 -1
- package/_mjs/MVar/api.mjs +150 -0
- package/_mjs/MVar/api.mjs.map +1 -0
- package/_mjs/MVar/definition.mjs +18 -0
- package/_mjs/MVar/definition.mjs.map +1 -0
- package/_mjs/MVar.mjs +4 -0
- package/_mjs/MVar.mjs.map +1 -0
- package/_mjs/Push/api.mjs +39 -36
- package/_mjs/Push/api.mjs.map +1 -1
- package/_mjs/Push/definition.mjs +5 -0
- package/_mjs/Push/definition.mjs.map +1 -1
- package/_mjs/Push/internal.mjs +4 -2
- package/_mjs/Push/internal.mjs.map +1 -1
- package/_mjs/Queue/api/dimapIO.mjs +11 -11
- package/_mjs/Queue/api/dimapIO.mjs.map +1 -1
- package/_mjs/Queue/api/filterInputIO.mjs +5 -5
- package/_mjs/Queue/api/filterInputIO.mjs.map +1 -1
- package/_mjs/Queue/api/filterOutputIO.mjs +8 -8
- package/_mjs/Queue/api/filterOutputIO.mjs.map +1 -1
- package/_mjs/Queue/definition.mjs +1 -0
- package/_mjs/Queue/definition.mjs.map +1 -1
- package/_mjs/Queue/internal.mjs +2 -2
- package/_mjs/Queue/internal.mjs.map +1 -1
- package/_mjs/Queue/strategy.mjs +2 -2
- package/_mjs/Queue/strategy.mjs.map +1 -1
- package/_mjs/Ref/Derived.mjs +6 -3
- package/_mjs/Ref/Derived.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/constructors.mjs +15 -7
- package/_mjs/Ref/Synchronized/constructors.mjs.map +1 -1
- package/_mjs/Ref/Synchronized/definition.mjs +13 -10
- package/_mjs/Ref/Synchronized/definition.mjs.map +1 -1
- package/_mjs/Ref/definition.mjs +1 -1
- package/_mjs/Ref/definition.mjs.map +1 -1
- package/_mjs/Ref.mjs +0 -1
- package/_mjs/Ref.mjs.map +1 -1
- package/_mjs/RefSubject/Synchronized/api.mjs +1 -1
- package/_mjs/RefSubject/definition.mjs +10 -3
- package/_mjs/RefSubject/definition.mjs.map +1 -1
- package/_mjs/Reloadable/definition.mjs +2 -1
- package/_mjs/Reloadable/definition.mjs.map +1 -1
- package/_mjs/STM/api/atomically.mjs +47 -0
- package/_mjs/STM/api/atomically.mjs.map +1 -0
- package/_mjs/STM/api.mjs +61 -88
- package/_mjs/STM/api.mjs.map +1 -1
- package/_mjs/STM/definition.mjs +27 -17
- package/_mjs/STM/definition.mjs.map +1 -1
- package/_mjs/STM/driver.mjs +3 -3
- package/_mjs/STM/driver.mjs.map +1 -1
- package/_mjs/STM/internal/Entry.mjs +5 -2
- package/_mjs/STM/internal/Entry.mjs.map +1 -1
- package/_mjs/STM/internal/TryCommit.mjs +6 -2
- package/_mjs/STM/internal/TryCommit.mjs.map +1 -1
- package/_mjs/STM/internal/Versioned.mjs +3 -1
- package/_mjs/STM/internal/Versioned.mjs.map +1 -1
- package/_mjs/STM.mjs +1 -0
- package/_mjs/STM.mjs.map +1 -1
- package/_mjs/Schedule/definition.mjs +1 -0
- package/_mjs/Schedule/definition.mjs.map +1 -1
- package/_mjs/Scope/api.mjs +1 -2
- package/_mjs/Scope/api.mjs.map +1 -1
- package/_mjs/Scope/definition.mjs +4 -2
- package/_mjs/Scope/definition.mjs.map +1 -1
- package/_mjs/ScopedRef/api.mjs +2 -2
- package/_mjs/ScopedRef/api.mjs.map +1 -1
- package/_mjs/ScopedRef/definition.mjs +3 -1
- package/_mjs/ScopedRef/definition.mjs.map +1 -1
- package/_mjs/State/api.mjs +1 -1
- package/_mjs/State/api.mjs.map +1 -1
- package/_mjs/State/definition.mjs +4 -1
- package/_mjs/State/definition.mjs.map +1 -1
- package/_mjs/State/internal.mjs +5 -2
- package/_mjs/State/internal.mjs.map +1 -1
- package/_mjs/Stream/api.mjs +1 -1
- package/_mjs/Stream/definition.mjs +2 -1
- package/_mjs/Stream/definition.mjs.map +1 -1
- package/_mjs/Stream/internal/Handoff.mjs +40 -32
- package/_mjs/Stream/internal/Handoff.mjs.map +1 -1
- package/_mjs/Stream/internal/SinkEndReason.mjs +6 -2
- package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -1
- package/_mjs/Subject/Atomic.mjs +4 -2
- package/_mjs/Subject/Atomic.mjs.map +1 -1
- package/_mjs/SubscriptionRef.mjs +1 -1
- package/_mjs/SupervisorPatch.mjs +3 -1
- package/_mjs/SupervisorPatch.mjs.map +1 -1
- package/_mjs/TExit/definition.mjs +25 -24
- package/_mjs/TExit/definition.mjs.map +1 -1
- package/_mjs/TFuture/constructors.mjs +1 -1
- package/_mjs/TReentrantLock/api.mjs +10 -9
- package/_mjs/TReentrantLock/api.mjs.map +1 -1
- package/_mjs/TRef/constructors.mjs +1 -1
- package/_mjs/TRef/definition.mjs +19 -20
- package/_mjs/TRef/definition.mjs.map +1 -1
- package/_mjs/TRef.mjs +0 -1
- package/_mjs/TRef.mjs.map +1 -1
- package/_mjs/TSemaphore/api.mjs +2 -2
- package/_mjs/TSemaphore/api.mjs.map +1 -1
- package/_mjs/TSemaphore/constructors.mjs +1 -1
- package/_mjs/internal/IsFatal.mjs +3 -1
- package/_mjs/internal/IsFatal.mjs.map +1 -1
- package/_src/Cached/definition.ts +6 -4
- package/_src/Cached/internal.ts +4 -4
- package/_src/Channel/api.ts +14 -15
- package/_src/Channel/definition.ts +37 -14
- package/_src/Channel/internal/ChannelExecutor.ts +14 -3
- package/_src/Channel/internal/MergeDecision.ts +11 -6
- package/_src/CountdownLatch.ts +1 -1
- package/_src/Differ/definition.ts +2 -4
- package/_src/Fiber/FiberRuntime.ts +54 -50
- package/_src/Fiber/definition.ts +15 -8
- package/_src/FiberRef/definition.ts +9 -4
- package/_src/FiberRefs/api.ts +1 -1
- package/_src/FiberRefs/definition.ts +1 -1
- package/_src/Future/api.ts +14 -5
- package/_src/Hub/api.ts +9 -7
- package/_src/Hub/definition.ts +30 -15
- package/_src/IO/api/interrupt.ts +72 -55
- package/_src/IO/api/onTermination.ts +8 -7
- package/_src/IO/api/sequenceT.ts +4 -6
- package/_src/IO/api.ts +23 -1
- package/_src/IO/definition.ts +36 -27
- package/_src/IO.ts +0 -1
- package/_src/Layer/MemoMap.ts +1 -1
- package/_src/Layer/api.ts +2 -2
- package/_src/Layer/definition.ts +18 -13
- package/_src/Logger/definition.ts +9 -4
- package/_src/MVar/api.ts +185 -0
- package/_src/MVar/definition.ts +45 -0
- package/_src/MVar.ts +4 -0
- package/_src/Push/api.ts +7 -4
- package/_src/Push/definition.ts +12 -3
- package/_src/Push/internal.ts +2 -2
- package/_src/Queue/api/dimapIO.ts +24 -13
- package/_src/Queue/api/filterInputIO.ts +9 -7
- package/_src/Queue/api/filterOutputIO.ts +9 -7
- package/_src/Queue/definition.ts +27 -18
- package/_src/Ref/Derived.ts +4 -1
- package/_src/Ref/Synchronized/constructors.ts +9 -0
- package/_src/Ref/Synchronized/definition.ts +5 -2
- package/_src/Ref/definition.ts +36 -25
- package/_src/Ref.ts +0 -1
- package/_src/RefSubject/definition.ts +19 -12
- package/_src/Reloadable/definition.ts +6 -1
- package/_src/STM/api/atomically.ts +43 -0
- package/_src/STM/api.ts +20 -38
- package/_src/STM/definition.ts +33 -20
- package/_src/STM/driver.ts +3 -3
- package/_src/STM/internal/Entry.ts +2 -2
- package/_src/STM/internal/TryCommit.ts +4 -4
- package/_src/STM/internal/Versioned.ts +1 -1
- package/_src/STM.ts +1 -0
- package/_src/Schedule/definition.ts +8 -3
- package/_src/Scope/definition.ts +2 -2
- package/_src/ScopedRef/definition.ts +1 -1
- package/_src/State/api.ts +1 -1
- package/_src/State/definition.ts +6 -3
- package/_src/State/internal.ts +8 -3
- package/_src/Stream/definition.ts +17 -5
- package/_src/Stream/internal/Handoff.ts +31 -24
- package/_src/Stream/internal/SinkEndReason.ts +2 -2
- package/_src/Subject/Atomic.ts +8 -4
- package/_src/SupervisorPatch.ts +1 -1
- package/_src/TExit/definition.ts +11 -12
- package/_src/TRef/definition.ts +18 -14
- package/_src/TRef.ts +0 -1
- package/_src/global.ts +4 -0
- package/_src/internal/IsFatal.ts +1 -1
- package/global.d.ts +4 -0
- package/internal/IsFatal.d.ts +1 -1
- package/package.json +2 -2
- package/IO/api/onExit.d.ts +0 -7
- package/Ref/symbols.d.ts +0 -30
- package/TRef/symbols.d.ts +0 -20
- package/_cjs/IO/api/onExit.cjs +0 -19
- package/_cjs/IO/api/onExit.cjs.map +0 -1
- package/_cjs/Ref/symbols.cjs +0 -37
- package/_cjs/Ref/symbols.cjs.map +0 -1
- package/_cjs/TRef/symbols.cjs +0 -27
- package/_cjs/TRef/symbols.cjs.map +0 -1
- package/_mjs/IO/api/onExit.mjs +0 -11
- package/_mjs/IO/api/onExit.mjs.map +0 -1
- package/_mjs/Ref/symbols.mjs +0 -25
- package/_mjs/Ref/symbols.mjs.map +0 -1
- package/_mjs/TRef/symbols.mjs +0 -17
- package/_mjs/TRef/symbols.mjs.map +0 -1
- package/_src/IO/api/onExit.ts +0 -11
- package/_src/Ref/symbols.ts +0 -29
- package/_src/TRef/symbols.ts +0 -19
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CachedInternal } from "@fncts/io/Cached/internal";
|
2
2
|
|
3
|
-
import { CachedTypeId } from "@fncts/io/Cached/internal";
|
3
|
+
import { CachedTypeId , CachedVariance } from "@fncts/io/Cached/internal";
|
4
4
|
|
5
5
|
/**
|
6
6
|
* A Cached is a possibly resourceful value that is loaded into memory, and
|
@@ -10,9 +10,11 @@ import { CachedTypeId } from "@fncts/io/Cached/internal";
|
|
10
10
|
* @tsplus companion fncts.io.CachedOps
|
11
11
|
*/
|
12
12
|
export class Cached<Error, Resource> {
|
13
|
-
readonly
|
14
|
-
|
15
|
-
|
13
|
+
readonly [CachedTypeId]: CachedTypeId = CachedTypeId;
|
14
|
+
declare [CachedVariance]: {
|
15
|
+
readonly _E: (_: never) => Error;
|
16
|
+
readonly _A: (_: never) => Resource;
|
17
|
+
};
|
16
18
|
}
|
17
19
|
|
18
20
|
/**
|
package/_src/Cached/internal.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
+
export const CachedVariance = Symbol.for("fncts.io.Cached.Variance");
|
2
|
+
export type CachedVariance = typeof CachedVariance;
|
3
|
+
|
1
4
|
export const CachedTypeId = Symbol.for("fncts.io.Cached");
|
2
5
|
export type CachedTypeId = typeof CachedTypeId;
|
3
6
|
|
4
|
-
export abstract class CachedInternal<Error, Resource> {
|
5
|
-
readonly _E!: () => Error;
|
6
|
-
readonly _A!: () => Resource;
|
7
|
-
readonly _typeId: CachedTypeId = CachedTypeId;
|
7
|
+
export abstract class CachedInternal<Error, Resource> extends Cached<Error, Resource> {
|
8
8
|
abstract get: FIO<Error, Resource>;
|
9
9
|
abstract refresh: FIO<Error, void>;
|
10
10
|
}
|
package/_src/Channel/api.ts
CHANGED
@@ -83,21 +83,21 @@ export function acquireReleaseExitWith<Env, InErr, InElem, InDone, OutErr, OutEl
|
|
83
83
|
/**
|
84
84
|
* Construct a resource Channel with Acquire / Release
|
85
85
|
*
|
86
|
-
* @tsplus static fncts.io.ChannelOps
|
86
|
+
* @tsplus static fncts.io.ChannelOps acquireReleaseOutWith
|
87
87
|
*/
|
88
|
-
export function
|
88
|
+
export function acquireReleaseOutWith<Env, OutErr, Acquired, Z>(
|
89
89
|
acquire: IO<Env, OutErr, Acquired>,
|
90
90
|
release: (a: Acquired) => URIO<Env, Z>,
|
91
91
|
): Channel<Env, unknown, unknown, unknown, OutErr, Acquired, void> {
|
92
|
-
return Channel.
|
92
|
+
return Channel.acquireReleaseOutExitWith(acquire, (z, _) => release(z));
|
93
93
|
}
|
94
94
|
|
95
95
|
/**
|
96
96
|
* Construct a resource Channel with Acquire / Release
|
97
97
|
*
|
98
|
-
* @tsplus static fncts.io.ChannelOps
|
98
|
+
* @tsplus static fncts.io.ChannelOps acquireReleaseOutExitWith
|
99
99
|
*/
|
100
|
-
export function
|
100
|
+
export function acquireReleaseOutExitWith<R, R2, E, Z>(
|
101
101
|
self: IO<R, E, Z>,
|
102
102
|
release: (z: Z, e: Exit<unknown, unknown>) => URIO<R2, unknown>,
|
103
103
|
): Channel<R | R2, unknown, unknown, unknown, E, Z, void> {
|
@@ -752,17 +752,16 @@ export function interrupt(fiberId: FiberId): Channel<never, unknown, unknown, un
|
|
752
752
|
export function scoped<R, E, A>(
|
753
753
|
io: Lazy<IO<R, E, A>>,
|
754
754
|
): Channel<Exclude<R, Scope>, unknown, unknown, unknown, E, A, unknown> {
|
755
|
-
return Channel.
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
(cause) => scope.close(Exit.failCause(cause))
|
760
|
-
(
|
755
|
+
return Channel.unwrap(
|
756
|
+
IO.uninterruptibleMask(({ restore }) =>
|
757
|
+
Scope.make.map((scope) =>
|
758
|
+
Channel.acquireReleaseOutExitWith(
|
759
|
+
restore(scope.extend(io)).tapErrorCause((cause) => scope.close(Exit.failCause(cause))),
|
760
|
+
(_, exit) => scope.close(exit),
|
761
761
|
),
|
762
762
|
),
|
763
763
|
),
|
764
|
-
|
765
|
-
).mapOut(([a]) => a);
|
764
|
+
);
|
766
765
|
}
|
767
766
|
|
768
767
|
/**
|
@@ -1019,12 +1018,12 @@ export function pipeTo<OutErr, OutElem, OutDone, Env1, OutErr1, OutElem1, OutDon
|
|
1019
1018
|
|
1020
1019
|
const ChannelFailureTypeId = Symbol.for("@principia/base/Channel/ChannelFailure");
|
1021
1020
|
class ChannelFailure<E> {
|
1022
|
-
readonly
|
1021
|
+
readonly [ChannelFailureTypeId] = ChannelFailureTypeId;
|
1023
1022
|
constructor(readonly error: E) {}
|
1024
1023
|
}
|
1025
1024
|
|
1026
1025
|
function isChannelFailure<E>(u: unknown): u is ChannelFailure<E> {
|
1027
|
-
return
|
1026
|
+
return isObject(u) && ChannelFailureTypeId in u;
|
1028
1027
|
}
|
1029
1028
|
|
1030
1029
|
/**
|
@@ -21,18 +21,27 @@ export const enum ChannelTag {
|
|
21
21
|
Provide = "Provide",
|
22
22
|
}
|
23
23
|
|
24
|
+
export const ChannelVariance = Symbol.for("fncts.io.Channel.Variance");
|
25
|
+
export type ChannelVariance = typeof ChannelVariance;
|
26
|
+
|
27
|
+
export const ChannelTypeId = Symbol.for("fncts.io.Channel");
|
28
|
+
export type ChannelTypeId = typeof ChannelTypeId;
|
29
|
+
|
24
30
|
/**
|
25
31
|
* @tsplus type fncts.io.Channel
|
26
32
|
* @tsplus companion fncts.io.ChannelOps
|
27
33
|
*/
|
28
34
|
export abstract class Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone> {
|
29
|
-
|
30
|
-
declare
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
readonly [ChannelTypeId]: ChannelTypeId = ChannelTypeId;
|
36
|
+
declare [ChannelVariance]: {
|
37
|
+
_Env: () => Env;
|
38
|
+
_InErr: (_: InErr) => void;
|
39
|
+
_InElem: (_: InElem) => void;
|
40
|
+
_InDone: (_: InDone) => void;
|
41
|
+
_OutErr: () => OutErr;
|
42
|
+
_OutElem: () => OutElem;
|
43
|
+
_OutDone: () => OutDone;
|
44
|
+
};
|
36
45
|
}
|
37
46
|
|
38
47
|
/**
|
@@ -43,49 +52,63 @@ export function unifyChannel<X extends Channel<any, any, any, any, any, any, any
|
|
43
52
|
): Channel<
|
44
53
|
[X] extends [
|
45
54
|
{
|
46
|
-
|
55
|
+
[ChannelVariance]: {
|
56
|
+
_Env: () => infer Env;
|
57
|
+
};
|
47
58
|
},
|
48
59
|
]
|
49
60
|
? Env
|
50
61
|
: never,
|
51
62
|
[X] extends [
|
52
63
|
{
|
53
|
-
|
64
|
+
[ChannelVariance]: {
|
65
|
+
_InErr: (_: infer InErr) => void;
|
66
|
+
};
|
54
67
|
},
|
55
68
|
]
|
56
69
|
? InErr
|
57
70
|
: never,
|
58
71
|
[X] extends [
|
59
72
|
{
|
60
|
-
|
73
|
+
[ChannelVariance]: {
|
74
|
+
_InElem: (_: infer InElem) => void;
|
75
|
+
};
|
61
76
|
},
|
62
77
|
]
|
63
78
|
? InElem
|
64
79
|
: never,
|
65
80
|
[X] extends [
|
66
81
|
{
|
67
|
-
|
82
|
+
[ChannelVariance]: {
|
83
|
+
_InDone: (_: infer InDone) => void;
|
84
|
+
};
|
68
85
|
},
|
69
86
|
]
|
70
87
|
? InDone
|
71
88
|
: never,
|
72
89
|
[X] extends [
|
73
90
|
{
|
74
|
-
|
91
|
+
[ChannelVariance]: {
|
92
|
+
_OutErr: () => infer OutErr;
|
93
|
+
};
|
75
94
|
},
|
76
95
|
]
|
77
96
|
? OutErr
|
78
97
|
: never,
|
79
98
|
[X] extends [
|
80
99
|
{
|
81
|
-
|
100
|
+
[ChannelVariance]: {
|
101
|
+
_OutElem: () => infer OutElem;
|
102
|
+
};
|
82
103
|
},
|
83
104
|
]
|
84
105
|
? OutElem
|
85
106
|
: never,
|
86
107
|
[X] extends [
|
87
108
|
{
|
88
|
-
|
109
|
+
[ChannelVariance]: {
|
110
|
+
_OutDone: () => infer OutDone;
|
111
|
+
};
|
89
112
|
},
|
90
113
|
]
|
91
114
|
? OutDone
|
@@ -1049,17 +1049,28 @@ export class ChannelExecutor<Env, InErr, InElem, InDone, OutErr, OutElem, OutDon
|
|
1049
1049
|
this.doneStack = this.doneStack.prepend(new ContinuationFinalizer(f));
|
1050
1050
|
}
|
1051
1051
|
|
1052
|
+
private provide<Env, OutErr, OutDone>(
|
1053
|
+
io: IO<Env, OutErr, OutDone>,
|
1054
|
+
__tsplusTrace?: string,
|
1055
|
+
): IO<Env, OutErr, OutDone> {
|
1056
|
+
if (this.providedEnv === null) {
|
1057
|
+
return io;
|
1058
|
+
} else {
|
1059
|
+
return io.provideEnvironment(this.providedEnv);
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
|
1052
1063
|
private runBracketOut(bracketOut: BracketOut<Env, unknown, unknown, unknown>): ChannelState<Env, unknown> | null {
|
1053
1064
|
return new State.Effect(
|
1054
|
-
IO.
|
1055
|
-
|
1065
|
+
IO.uninterruptible(
|
1066
|
+
this.provide(bracketOut.acquire).matchCauseIO(
|
1056
1067
|
(cause) =>
|
1057
1068
|
IO.succeed(() => {
|
1058
1069
|
this.currentChannel = Channel.failCause(cause);
|
1059
1070
|
}),
|
1060
1071
|
(out) =>
|
1061
1072
|
IO.succeed(() => {
|
1062
|
-
this.addFinalizer((e) => bracketOut.finalizer(out, e));
|
1073
|
+
this.addFinalizer((e) => this.provide(bracketOut.finalizer(out, e)));
|
1063
1074
|
this.currentChannel = Channel.write(() => out);
|
1064
1075
|
}),
|
1065
1076
|
),
|
@@ -3,6 +3,9 @@ export const enum MergeDecisionTag {
|
|
3
3
|
Await = "Await",
|
4
4
|
}
|
5
5
|
|
6
|
+
export const MergeDecisionVariance = Symbol.for("fncts.io.Channel.MergeDecision.Variance");
|
7
|
+
export type MergeDecisionVariance = typeof MergeDecisionVariance;
|
8
|
+
|
6
9
|
export const MergeDecisionTypeId = Symbol.for("fncts.io.Channel.MergeDecision");
|
7
10
|
export type MergeDecisionTypeId = typeof MergeDecisionTypeId;
|
8
11
|
|
@@ -11,12 +14,14 @@ export type MergeDecisionTypeId = typeof MergeDecisionTypeId;
|
|
11
14
|
* @tsplus companion fncts.io.Channel.MergeDecisionOps
|
12
15
|
*/
|
13
16
|
export abstract class MergeDecision<R, E0, Z0, E, Z> {
|
14
|
-
readonly
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
readonly [MergeDecisionTypeId]: MergeDecisionTypeId = MergeDecisionTypeId;
|
18
|
+
declare [MergeDecisionVariance]: {
|
19
|
+
readonly _R: (_: never) => R;
|
20
|
+
readonly _E0: (_: E0) => void;
|
21
|
+
readonly _Z0: (_: Z0) => void;
|
22
|
+
readonly _E: (_: never) => E;
|
23
|
+
readonly _Z: (_: never) => Z;
|
24
|
+
};
|
20
25
|
}
|
21
26
|
|
22
27
|
/**
|
package/_src/CountdownLatch.ts
CHANGED
@@ -6,7 +6,7 @@ export type CountdownLatchTypeId = typeof CountdownLatchTypeId;
|
|
6
6
|
* @tsplus companion fncts.io.CountdownLatchOps
|
7
7
|
*/
|
8
8
|
export class CountdownLatch {
|
9
|
-
readonly
|
9
|
+
readonly [CountdownLatchTypeId]: CountdownLatchTypeId = CountdownLatchTypeId;
|
10
10
|
constructor(private _count: Ref<number>, private _waiters: Future<never, void>) {}
|
11
11
|
|
12
12
|
readonly await: UIO<void> = this._waiters.await;
|
@@ -5,10 +5,8 @@ export type DifferTypeId = typeof DifferTypeId;
|
|
5
5
|
* @tsplus type fncts.io.Differ
|
6
6
|
* @tsplus companion fncts.io.DifferOps
|
7
7
|
*/
|
8
|
-
export abstract class Differ<Value, Patch> {
|
9
|
-
readonly
|
10
|
-
declare _Value: Value;
|
11
|
-
declare _Patch: Patch;
|
8
|
+
export abstract class Differ<in out Value, in out Patch> {
|
9
|
+
readonly [DifferTypeId]: DifferTypeId = DifferTypeId;
|
12
10
|
abstract readonly empty: Patch;
|
13
11
|
abstract combine(first: Patch, second: Patch): Patch;
|
14
12
|
abstract diff(oldValue: Value, newValue: Value): Patch;
|
@@ -3,7 +3,7 @@ import type { OnFailure, OnSuccess, OnSuccessAndFailure, UIO } from "../IO/defin
|
|
3
3
|
import type { RuntimeFlags } from "../RuntimeFlags.js";
|
4
4
|
|
5
5
|
import { Trace } from "@fncts/base/data/Trace";
|
6
|
-
import { FiberTypeId } from "@fncts/io/Fiber/definition";
|
6
|
+
import { FiberTypeId, FiberVariance } from "@fncts/io/Fiber/definition";
|
7
7
|
import { StackTraceBuilder } from "@fncts/io/internal/StackTraceBuilder";
|
8
8
|
|
9
9
|
import { Done, Suspended } from "../FiberStatus.js";
|
@@ -12,23 +12,18 @@ import { FiberStatusTag } from "../FiberStatus.js";
|
|
12
12
|
import { LinkedQueue } from "../internal/MutableQueue.js";
|
13
13
|
import { isIO } from "../IO/definition.js";
|
14
14
|
import { WhileLoop } from "../IO/definition.js";
|
15
|
-
import {
|
15
|
+
import { IOOpCode } from "../IO/definition.js";
|
16
16
|
import { isIOError } from "../IO/definition.js";
|
17
17
|
import { RuntimeFlag } from "../RuntimeFlag.js";
|
18
18
|
import { FiberMessage, FiberMessageTag } from "./FiberMessage.js";
|
19
19
|
|
20
|
-
const enum ContinuationTag {
|
21
|
-
RevertFlags = "RevertFlags",
|
22
|
-
UpdateTrace = "UpdateTrace",
|
23
|
-
}
|
24
|
-
|
25
20
|
export class RevertFlags {
|
26
|
-
readonly
|
21
|
+
readonly ioOpCode = IOOpCode.RevertFlags;
|
27
22
|
constructor(readonly patch: RuntimeFlags.Patch, readonly trace?: string) {}
|
28
23
|
}
|
29
24
|
|
30
25
|
export class UpdateTrace {
|
31
|
-
readonly
|
26
|
+
readonly ioOpCode = IOOpCode.UpdateTrace;
|
32
27
|
constructor(readonly trace?: string) {}
|
33
28
|
}
|
34
29
|
|
@@ -44,10 +39,13 @@ export type Continuation =
|
|
44
39
|
* @tsplus type fncts.io.Fiber
|
45
40
|
*/
|
46
41
|
export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
47
|
-
readonly
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
readonly [FiberTypeId]: FiberTypeId = FiberTypeId;
|
43
|
+
declare [FiberVariance]: {
|
44
|
+
readonly _E: (_: never) => E;
|
45
|
+
readonly _A: (_: never) => A;
|
46
|
+
};
|
47
|
+
readonly _tag = "RuntimeFiber";
|
48
|
+
|
51
49
|
constructor(readonly fiberId: FiberId.Runtime, fiberRefs0: FiberRefs, readonly runtimeFlags0: RuntimeFlags) {
|
52
50
|
this._fiberRefs = fiberRefs0;
|
53
51
|
this._runtimeFlags = runtimeFlags0;
|
@@ -269,7 +267,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
269
267
|
}
|
270
268
|
} catch (e) {
|
271
269
|
if (isIO(e)) {
|
272
|
-
if (IO.concrete(e).
|
270
|
+
if (IO.concrete(e).ioOpCode === IOOpCode.YieldNow) {
|
273
271
|
if (this._runtimeFlags.cooperativeYielding) {
|
274
272
|
this.tell(FiberMessage.YieldNow);
|
275
273
|
this.tell(FiberMessage.Resume(IO.unit));
|
@@ -277,10 +275,10 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
277
275
|
} else {
|
278
276
|
effect = IO.unit;
|
279
277
|
}
|
280
|
-
} else if (IO.concrete(e).
|
278
|
+
} else if (IO.concrete(e).ioOpCode === IOOpCode.Async) {
|
281
279
|
effect = null!;
|
282
280
|
} else {
|
283
|
-
throw new Error(`Unhandled op ${IO.concrete(e).
|
281
|
+
throw new Error(`Unhandled op ${IO.concrete(e).ioOpCode}`);
|
284
282
|
}
|
285
283
|
} else {
|
286
284
|
throw e;
|
@@ -317,18 +315,18 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
317
315
|
cur = IO.concrete(IO.yieldNow.flatMap(() => oldCur, trace));
|
318
316
|
}
|
319
317
|
try {
|
320
|
-
switch (cur.
|
321
|
-
case
|
318
|
+
switch (cur.ioOpCode) {
|
319
|
+
case IOOpCode.Sync: {
|
322
320
|
const value = cur.evaluate();
|
323
321
|
const cont = this.getNextSuccessCont();
|
324
322
|
if (cont) {
|
325
|
-
switch (cont.
|
326
|
-
case
|
327
|
-
case
|
323
|
+
switch (cont.ioOpCode) {
|
324
|
+
case IOOpCode.OnSuccess:
|
325
|
+
case IOOpCode.OnSuccessAndFailure: {
|
328
326
|
cur = IO.concrete(cont.successK(value));
|
329
327
|
break;
|
330
328
|
}
|
331
|
-
case
|
329
|
+
case IOOpCode.WhileLoop: {
|
332
330
|
cont.process(value);
|
333
331
|
if (cont.check()) {
|
334
332
|
this.stack.push(cont);
|
@@ -338,7 +336,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
338
336
|
}
|
339
337
|
break;
|
340
338
|
}
|
341
|
-
case
|
339
|
+
case IOOpCode.RevertFlags: {
|
342
340
|
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
343
341
|
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
344
342
|
cur = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
@@ -347,7 +345,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
347
345
|
}
|
348
346
|
break;
|
349
347
|
}
|
350
|
-
case
|
348
|
+
case IOOpCode.UpdateTrace: {
|
351
349
|
if (cont.trace !== undefined) lastTrace = cont.trace;
|
352
350
|
cur = IO.concrete(IO.unit);
|
353
351
|
break;
|
@@ -358,20 +356,20 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
358
356
|
}
|
359
357
|
break;
|
360
358
|
}
|
361
|
-
case
|
362
|
-
case
|
363
|
-
case
|
359
|
+
case IOOpCode.OnSuccessAndFailure:
|
360
|
+
case IOOpCode.OnFailure:
|
361
|
+
case IOOpCode.OnSuccess: {
|
364
362
|
this.stack.push(cur);
|
365
363
|
cur = IO.concrete(cur.first);
|
366
364
|
break;
|
367
365
|
}
|
368
|
-
case
|
366
|
+
case IOOpCode.Async: {
|
369
367
|
this.asyncTrace = lastTrace;
|
370
368
|
this.asyncBlockinOn = cur.blockingOn();
|
371
369
|
this.initiateAsync(this._runtimeFlags, cur.registerCallback);
|
372
370
|
throw cur;
|
373
371
|
}
|
374
|
-
case
|
372
|
+
case IOOpCode.UpdateRuntimeFlagsWithin: {
|
375
373
|
const updateFlags = cur.update;
|
376
374
|
const oldRuntimeFlags = this._runtimeFlags;
|
377
375
|
const newRuntimeFlags = updateFlags.patch(oldRuntimeFlags);
|
@@ -390,25 +388,25 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
390
388
|
}
|
391
389
|
break;
|
392
390
|
}
|
393
|
-
case
|
391
|
+
case IOOpCode.GenerateStackTrace: {
|
394
392
|
cur = IO.concrete(IO.succeedNow(this.generateStackTrace()));
|
395
393
|
break;
|
396
394
|
}
|
397
|
-
case
|
395
|
+
case IOOpCode.Stateful: {
|
398
396
|
cur = IO.concrete(cur.onState(this, new Running(this._runtimeFlags, lastTrace)));
|
399
397
|
break;
|
400
398
|
}
|
401
|
-
case
|
399
|
+
case IOOpCode.SucceedNow: {
|
402
400
|
const oldCur = cur;
|
403
401
|
const cont = this.getNextSuccessCont();
|
404
402
|
if (cont) {
|
405
|
-
switch (cont.
|
406
|
-
case
|
407
|
-
case
|
403
|
+
switch (cont.ioOpCode) {
|
404
|
+
case IOOpCode.OnSuccess:
|
405
|
+
case IOOpCode.OnSuccessAndFailure: {
|
408
406
|
cur = IO.concrete(cont.successK(oldCur.value));
|
409
407
|
break;
|
410
408
|
}
|
411
|
-
case
|
409
|
+
case IOOpCode.WhileLoop: {
|
412
410
|
cont.process(oldCur.value);
|
413
411
|
if (cont.check()) {
|
414
412
|
this.stack.push(cont);
|
@@ -418,14 +416,14 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
418
416
|
}
|
419
417
|
break;
|
420
418
|
}
|
421
|
-
case
|
419
|
+
case IOOpCode.RevertFlags: {
|
422
420
|
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
423
421
|
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
424
422
|
cur = IO.concrete(IO.failCauseNow(this.getInterruptedCause()));
|
425
423
|
}
|
426
424
|
break;
|
427
425
|
}
|
428
|
-
case
|
426
|
+
case IOOpCode.UpdateTrace: {
|
429
427
|
if (cont.trace !== undefined) lastTrace = cont.trace;
|
430
428
|
cur = IO.concrete(IO.unit);
|
431
429
|
break;
|
@@ -436,13 +434,13 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
436
434
|
}
|
437
435
|
break;
|
438
436
|
}
|
439
|
-
case
|
437
|
+
case IOOpCode.Fail: {
|
440
438
|
const cause = cur.cause();
|
441
439
|
const cont = this.getNextFailCont();
|
442
440
|
if (cont) {
|
443
|
-
switch (cont.
|
444
|
-
case
|
445
|
-
case
|
441
|
+
switch (cont.ioOpCode) {
|
442
|
+
case IOOpCode.OnFailure:
|
443
|
+
case IOOpCode.OnSuccessAndFailure: {
|
446
444
|
if (!(this._runtimeFlags.interruptible && this.isInterrupted())) {
|
447
445
|
cur = IO.concrete(cont.failureK(cause));
|
448
446
|
} else {
|
@@ -450,7 +448,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
450
448
|
}
|
451
449
|
break;
|
452
450
|
}
|
453
|
-
case
|
451
|
+
case IOOpCode.RevertFlags: {
|
454
452
|
this.patchRuntimeFlags(this._runtimeFlags, cont.patch);
|
455
453
|
if (this._runtimeFlags.interruptible && this.isInterrupted()) {
|
456
454
|
const interruptedCause = this.getInterruptedCause();
|
@@ -462,7 +460,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
462
460
|
}
|
463
461
|
break;
|
464
462
|
}
|
465
|
-
case
|
463
|
+
case IOOpCode.UpdateTrace: {
|
466
464
|
if (cont.trace !== undefined) lastTrace = cont.trace;
|
467
465
|
cur = IO.concrete(IO.unit);
|
468
466
|
break;
|
@@ -473,12 +471,12 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
473
471
|
}
|
474
472
|
break;
|
475
473
|
}
|
476
|
-
case
|
474
|
+
case IOOpCode.UpdateRuntimeFlags: {
|
477
475
|
this.patchRuntimeFlags(this._runtimeFlags, cur.update);
|
478
476
|
cur = IO.concrete(IO.unit);
|
479
477
|
break;
|
480
478
|
}
|
481
|
-
case
|
479
|
+
case IOOpCode.WhileLoop: {
|
482
480
|
const iterate = cur;
|
483
481
|
const check = iterate.check;
|
484
482
|
const body = iterate.body;
|
@@ -490,14 +488,20 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
490
488
|
}
|
491
489
|
break;
|
492
490
|
}
|
493
|
-
case
|
491
|
+
case IOOpCode.YieldNow: {
|
494
492
|
throw cur;
|
495
493
|
}
|
494
|
+
case IOOpCode.Commit: {
|
495
|
+
cur = IO.concrete(cur.commit);
|
496
|
+
}
|
496
497
|
}
|
497
498
|
} catch (e) {
|
498
499
|
if (isIOError(e)) {
|
499
500
|
cur = IO.concrete(IO.failCauseNow(e.cause));
|
500
|
-
} else if (
|
501
|
+
} else if (
|
502
|
+
isIO(e) &&
|
503
|
+
(IO.concrete(e).ioOpCode === IOOpCode.Async || IO.concrete(e).ioOpCode === IOOpCode.YieldNow)
|
504
|
+
) {
|
501
505
|
throw e;
|
502
506
|
} else if (isInterruptedException(e)) {
|
503
507
|
cur = IO.concrete(IO.failCauseNow(Cause.both(Cause.halt(e), Cause.interrupt(FiberId.none))));
|
@@ -795,7 +799,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
795
799
|
getNextSuccessCont() {
|
796
800
|
while (this.stack.hasNext) {
|
797
801
|
const frame = this.stack.pop()!;
|
798
|
-
if (frame.
|
802
|
+
if (frame.ioOpCode !== IOOpCode.OnFailure) {
|
799
803
|
return frame;
|
800
804
|
}
|
801
805
|
}
|
@@ -804,7 +808,7 @@ export class FiberRuntime<E, A> implements Fiber.Runtime<E, A> {
|
|
804
808
|
getNextFailCont() {
|
805
809
|
while (this.stack.hasNext) {
|
806
810
|
const frame = this.stack.pop()!;
|
807
|
-
if (frame.
|
811
|
+
if (frame.ioOpCode !== IOOpCode.OnSuccess && frame.ioOpCode !== IOOpCode.WhileLoop) {
|
808
812
|
return frame;
|
809
813
|
}
|
810
814
|
}
|
package/_src/Fiber/definition.ts
CHANGED
@@ -3,9 +3,11 @@ import type { FiberRuntime } from "@fncts/io/Fiber/FiberRuntime";
|
|
3
3
|
import type { FiberStatus } from "@fncts/io/FiberStatus";
|
4
4
|
import type { UIO } from "@fncts/io/IO/definition";
|
5
5
|
|
6
|
-
import { IterableWeakMap } from "@fncts/base/collection/weak/IterableWeakMap";
|
7
6
|
import { IterableWeakSet } from "@fncts/base/collection/weak/IterableWeakSet";
|
8
7
|
|
8
|
+
export const FiberVariance = Symbol.for("fncts.io.Fiber.Variance");
|
9
|
+
export type FiberVariance = typeof FiberVariance;
|
10
|
+
|
9
11
|
export const FiberTypeId = Symbol.for("fncts.io.Fiber");
|
10
12
|
export type FiberTypeId = typeof FiberTypeId;
|
11
13
|
|
@@ -13,9 +15,11 @@ export type FiberTypeId = typeof FiberTypeId;
|
|
13
15
|
* @tsplus type fncts.io.Fiber
|
14
16
|
*/
|
15
17
|
export interface Fiber<E, A> {
|
16
|
-
readonly
|
17
|
-
readonly
|
18
|
-
|
18
|
+
readonly [FiberTypeId]: FiberTypeId;
|
19
|
+
readonly [FiberVariance]: {
|
20
|
+
readonly _E: (_: never) => E;
|
21
|
+
readonly _A: (_: never) => A;
|
22
|
+
};
|
19
23
|
}
|
20
24
|
|
21
25
|
/**
|
@@ -90,9 +94,12 @@ export interface RuntimeFiber<E, A> extends FiberCommon<E, A> {
|
|
90
94
|
export class SyntheticFiber<E, A> implements FiberCommon<E, A> {
|
91
95
|
readonly _tag = "SyntheticFiber";
|
92
96
|
|
93
|
-
readonly
|
94
|
-
|
95
|
-
|
97
|
+
readonly [FiberTypeId]: FiberTypeId = FiberTypeId;
|
98
|
+
declare [FiberVariance]: {
|
99
|
+
readonly _E: (_: never) => E;
|
100
|
+
readonly _A: (_: never) => A;
|
101
|
+
};
|
102
|
+
|
96
103
|
readonly await;
|
97
104
|
|
98
105
|
constructor(
|
@@ -118,7 +125,7 @@ export function concrete<E, A>(_fiber: Fiber<E, A>): asserts _fiber is ConcreteF
|
|
118
125
|
}
|
119
126
|
|
120
127
|
export function isFiber(u: unknown): u is Fiber<unknown, unknown> {
|
121
|
-
return
|
128
|
+
return isObject(u) && FiberTypeId in u;
|
122
129
|
}
|
123
130
|
|
124
131
|
/**
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { AtomicNumber } from "@fncts/base/internal/AtomicNumber";
|
2
2
|
|
3
|
-
export const
|
3
|
+
export const FiberRefVariance = Symbol.for("fncts.io.FiberRef.Variance");
|
4
|
+
export type FiberRefVariance = typeof FiberRefVariance;
|
5
|
+
|
6
|
+
export const FiberRefTypeId = Symbol.for("fncts.io.FiberRef");
|
4
7
|
export type FiberRefTypeId = typeof FiberRefTypeId;
|
5
8
|
|
6
9
|
/**
|
@@ -8,8 +11,10 @@ export type FiberRefTypeId = typeof FiberRefTypeId;
|
|
8
11
|
* @tsplus companion fncts.io.FiberRefOps
|
9
12
|
*/
|
10
13
|
export abstract class FiberRef<Value> {
|
11
|
-
readonly
|
12
|
-
|
14
|
+
readonly [FiberRefTypeId]: FiberRefTypeId = FiberRefTypeId;
|
15
|
+
declare [FiberRefVariance]: {
|
16
|
+
readonly _Value: (_: Value) => Value;
|
17
|
+
};
|
13
18
|
readonly _Patch!: unknown;
|
14
19
|
}
|
15
20
|
|
@@ -50,7 +55,7 @@ export class FiberRefInternal<Value, Patch> extends FiberRef<Value> implements H
|
|
50
55
|
}
|
51
56
|
|
52
57
|
export function isFiberRef(u: unknown): u is FiberRef<unknown> {
|
53
|
-
return
|
58
|
+
return isObject(u) && FiberRefTypeId in u;
|
54
59
|
}
|
55
60
|
|
56
61
|
type Concrete<Value, Patch> = FiberRefInternal<Value, Patch>;
|