@clayroach/effect 3.19.14-source-capture.6 → 3.19.14-source-capture.8
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/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +0 -1101
- package/src/Array.ts +0 -3589
- package/src/BigDecimal.ts +0 -1349
- package/src/BigInt.ts +0 -643
- package/src/Boolean.ts +0 -287
- package/src/Brand.ts +0 -360
- package/src/Cache.ts +0 -281
- package/src/Cause.ts +0 -1555
- package/src/Channel.ts +0 -2355
- package/src/ChildExecutorDecision.ts +0 -146
- package/src/Chunk.ts +0 -1495
- package/src/Clock.ts +0 -111
- package/src/Config.ts +0 -542
- package/src/ConfigError.ts +0 -270
- package/src/ConfigProvider.ts +0 -333
- package/src/ConfigProviderPathPatch.ts +0 -100
- package/src/Console.ts +0 -226
- package/src/Context.ts +0 -585
- package/src/Cron.ts +0 -706
- package/src/Data.ts +0 -596
- package/src/DateTime.ts +0 -1686
- package/src/DefaultServices.ts +0 -34
- package/src/Deferred.ts +0 -301
- package/src/Differ.ts +0 -450
- package/src/Duration.ts +0 -1000
- package/src/Effect.ts +0 -14839
- package/src/Effectable.ts +0 -107
- package/src/Either.ts +0 -1040
- package/src/Encoding.ts +0 -195
- package/src/Equal.ts +0 -98
- package/src/Equivalence.ts +0 -235
- package/src/ExecutionPlan.ts +0 -308
- package/src/ExecutionStrategy.ts +0 -119
- package/src/Exit.ts +0 -467
- package/src/FastCheck.ts +0 -9
- package/src/Fiber.ts +0 -744
- package/src/FiberHandle.ts +0 -540
- package/src/FiberId.ts +0 -195
- package/src/FiberMap.ts +0 -656
- package/src/FiberRef.ts +0 -431
- package/src/FiberRefs.ts +0 -204
- package/src/FiberRefsPatch.ts +0 -105
- package/src/FiberSet.ts +0 -491
- package/src/FiberStatus.ts +0 -108
- package/src/Function.ts +0 -1222
- package/src/GlobalValue.ts +0 -53
- package/src/Graph.ts +0 -3732
- package/src/GroupBy.ts +0 -103
- package/src/HKT.ts +0 -45
- package/src/Hash.ts +0 -195
- package/src/HashMap.ts +0 -519
- package/src/HashRing.ts +0 -317
- package/src/HashSet.ts +0 -2346
- package/src/Inspectable.ts +0 -287
- package/src/Iterable.ts +0 -1119
- package/src/JSONSchema.ts +0 -1044
- package/src/KeyedPool.ts +0 -167
- package/src/Layer.ts +0 -1251
- package/src/LayerMap.ts +0 -436
- package/src/List.ts +0 -977
- package/src/LogLevel.ts +0 -285
- package/src/LogSpan.ts +0 -25
- package/src/Logger.ts +0 -702
- package/src/Mailbox.ts +0 -268
- package/src/ManagedRuntime.ts +0 -180
- package/src/Match.ts +0 -1477
- package/src/MergeDecision.ts +0 -95
- package/src/MergeState.ts +0 -172
- package/src/MergeStrategy.ts +0 -107
- package/src/Metric.ts +0 -780
- package/src/MetricBoundaries.ts +0 -69
- package/src/MetricHook.ts +0 -151
- package/src/MetricKey.ts +0 -224
- package/src/MetricKeyType.ts +0 -262
- package/src/MetricLabel.ts +0 -47
- package/src/MetricPair.ts +0 -71
- package/src/MetricPolling.ts +0 -148
- package/src/MetricRegistry.ts +0 -48
- package/src/MetricState.ts +0 -257
- package/src/Micro.ts +0 -4405
- package/src/ModuleVersion.ts +0 -18
- package/src/MutableHashMap.ts +0 -411
- package/src/MutableHashSet.ts +0 -706
- package/src/MutableList.ts +0 -297
- package/src/MutableQueue.ts +0 -227
- package/src/MutableRef.ts +0 -202
- package/src/NonEmptyIterable.ts +0 -32
- package/src/Number.ts +0 -1071
- package/src/Option.ts +0 -2170
- package/src/Order.ts +0 -373
- package/src/Ordering.ts +0 -111
- package/src/ParseResult.ts +0 -2031
- package/src/PartitionedSemaphore.ts +0 -200
- package/src/Pipeable.ts +0 -566
- package/src/Pool.ts +0 -204
- package/src/Predicate.ts +0 -1405
- package/src/Pretty.ts +0 -205
- package/src/PrimaryKey.ts +0 -23
- package/src/PubSub.ts +0 -182
- package/src/Queue.ts +0 -644
- package/src/Random.ts +0 -204
- package/src/RateLimiter.ts +0 -138
- package/src/RcMap.ts +0 -141
- package/src/RcRef.ts +0 -122
- package/src/Readable.ts +0 -93
- package/src/Record.ts +0 -1274
- package/src/RedBlackTree.ts +0 -421
- package/src/Redacted.ts +0 -144
- package/src/Ref.ts +0 -180
- package/src/RegExp.ts +0 -38
- package/src/Reloadable.ts +0 -127
- package/src/Request.ts +0 -347
- package/src/RequestBlock.ts +0 -118
- package/src/RequestResolver.ts +0 -366
- package/src/Resource.ts +0 -119
- package/src/Runtime.ts +0 -383
- package/src/RuntimeFlags.ts +0 -368
- package/src/RuntimeFlagsPatch.ts +0 -183
- package/src/STM.ts +0 -2045
- package/src/Schedule.ts +0 -2219
- package/src/ScheduleDecision.ts +0 -62
- package/src/ScheduleInterval.ts +0 -151
- package/src/ScheduleIntervals.ts +0 -122
- package/src/Scheduler.ts +0 -353
- package/src/Schema.ts +0 -10914
- package/src/SchemaAST.ts +0 -3043
- package/src/Scope.ts +0 -204
- package/src/ScopedCache.ts +0 -151
- package/src/ScopedRef.ts +0 -117
- package/src/Secret.ts +0 -88
- package/src/SingleProducerAsyncInput.ts +0 -67
- package/src/Sink.ts +0 -1461
- package/src/SortedMap.ts +0 -287
- package/src/SortedSet.ts +0 -390
- package/src/Stream.ts +0 -6468
- package/src/StreamEmit.ts +0 -136
- package/src/StreamHaltStrategy.ts +0 -123
- package/src/Streamable.ts +0 -45
- package/src/String.ts +0 -778
- package/src/Struct.ts +0 -243
- package/src/Subscribable.ts +0 -100
- package/src/SubscriptionRef.ts +0 -298
- package/src/Supervisor.ts +0 -240
- package/src/Symbol.ts +0 -29
- package/src/SynchronizedRef.ts +0 -270
- package/src/TArray.ts +0 -495
- package/src/TDeferred.ts +0 -100
- package/src/TMap.ts +0 -515
- package/src/TPriorityQueue.ts +0 -223
- package/src/TPubSub.ts +0 -200
- package/src/TQueue.ts +0 -432
- package/src/TRandom.ts +0 -129
- package/src/TReentrantLock.ts +0 -224
- package/src/TRef.ts +0 -178
- package/src/TSemaphore.ts +0 -129
- package/src/TSet.ts +0 -365
- package/src/TSubscriptionRef.ts +0 -192
- package/src/Take.ts +0 -258
- package/src/TestAnnotation.ts +0 -158
- package/src/TestAnnotationMap.ts +0 -119
- package/src/TestAnnotations.ts +0 -117
- package/src/TestClock.ts +0 -556
- package/src/TestConfig.ts +0 -47
- package/src/TestContext.ts +0 -36
- package/src/TestLive.ts +0 -53
- package/src/TestServices.ts +0 -390
- package/src/TestSized.ts +0 -55
- package/src/Tracer.ts +0 -198
- package/src/Trie.ts +0 -840
- package/src/Tuple.ts +0 -305
- package/src/Types.ts +0 -353
- package/src/Unify.ts +0 -113
- package/src/UpstreamPullRequest.ts +0 -117
- package/src/UpstreamPullStrategy.ts +0 -121
- package/src/Utils.ts +0 -809
- package/src/index.ts +0 -1561
- package/src/internal/array.ts +0 -8
- package/src/internal/blockedRequests.ts +0 -520
- package/src/internal/cache.ts +0 -733
- package/src/internal/cause.ts +0 -1050
- package/src/internal/channel/channelExecutor.ts +0 -1200
- package/src/internal/channel/channelState.ts +0 -134
- package/src/internal/channel/childExecutorDecision.ts +0 -96
- package/src/internal/channel/continuation.ts +0 -200
- package/src/internal/channel/mergeDecision.ts +0 -113
- package/src/internal/channel/mergeState.ts +0 -120
- package/src/internal/channel/mergeStrategy.ts +0 -72
- package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
- package/src/internal/channel/subexecutor.ts +0 -229
- package/src/internal/channel/upstreamPullRequest.ts +0 -84
- package/src/internal/channel/upstreamPullStrategy.ts +0 -87
- package/src/internal/channel.ts +0 -2603
- package/src/internal/clock.ts +0 -95
- package/src/internal/completedRequestMap.ts +0 -9
- package/src/internal/concurrency.ts +0 -54
- package/src/internal/config.ts +0 -716
- package/src/internal/configError.ts +0 -304
- package/src/internal/configProvider/pathPatch.ts +0 -97
- package/src/internal/configProvider.ts +0 -799
- package/src/internal/console.ts +0 -153
- package/src/internal/context.ts +0 -337
- package/src/internal/core-effect.ts +0 -2293
- package/src/internal/core-stream.ts +0 -998
- package/src/internal/core.ts +0 -3273
- package/src/internal/data.ts +0 -36
- package/src/internal/dataSource.ts +0 -327
- package/src/internal/dateTime.ts +0 -1277
- package/src/internal/defaultServices/console.ts +0 -100
- package/src/internal/defaultServices.ts +0 -163
- package/src/internal/deferred.ts +0 -46
- package/src/internal/differ/chunkPatch.ts +0 -211
- package/src/internal/differ/contextPatch.ts +0 -232
- package/src/internal/differ/hashMapPatch.ts +0 -220
- package/src/internal/differ/hashSetPatch.ts +0 -176
- package/src/internal/differ/orPatch.ts +0 -311
- package/src/internal/differ/readonlyArrayPatch.ts +0 -210
- package/src/internal/differ.ts +0 -200
- package/src/internal/doNotation.ts +0 -80
- package/src/internal/effect/circular.ts +0 -905
- package/src/internal/effectable.ts +0 -131
- package/src/internal/either.ts +0 -110
- package/src/internal/encoding/base64.ts +0 -286
- package/src/internal/encoding/base64Url.ts +0 -29
- package/src/internal/encoding/common.ts +0 -51
- package/src/internal/encoding/hex.ts +0 -315
- package/src/internal/errors.ts +0 -7
- package/src/internal/executionPlan.ts +0 -114
- package/src/internal/executionStrategy.ts +0 -74
- package/src/internal/fiber.ts +0 -388
- package/src/internal/fiberId.ts +0 -267
- package/src/internal/fiberMessage.ts +0 -82
- package/src/internal/fiberRefs/patch.ts +0 -144
- package/src/internal/fiberRefs.ts +0 -297
- package/src/internal/fiberRuntime.ts +0 -3915
- package/src/internal/fiberScope.ts +0 -71
- package/src/internal/fiberStatus.ts +0 -119
- package/src/internal/groupBy.ts +0 -530
- package/src/internal/hashMap/array.ts +0 -49
- package/src/internal/hashMap/bitwise.ts +0 -32
- package/src/internal/hashMap/config.ts +0 -14
- package/src/internal/hashMap/keySet.ts +0 -8
- package/src/internal/hashMap/node.ts +0 -391
- package/src/internal/hashMap.ts +0 -586
- package/src/internal/hashSet.ts +0 -323
- package/src/internal/keyedPool.ts +0 -244
- package/src/internal/layer/circular.ts +0 -228
- package/src/internal/layer.ts +0 -1487
- package/src/internal/logSpan.ts +0 -20
- package/src/internal/logger-circular.ts +0 -24
- package/src/internal/logger.ts +0 -485
- package/src/internal/mailbox.ts +0 -561
- package/src/internal/managedRuntime/circular.ts +0 -6
- package/src/internal/managedRuntime.ts +0 -134
- package/src/internal/matcher.ts +0 -652
- package/src/internal/metric/boundaries.ts +0 -75
- package/src/internal/metric/hook.ts +0 -483
- package/src/internal/metric/key.ts +0 -167
- package/src/internal/metric/keyType.ts +0 -238
- package/src/internal/metric/label.ts +0 -41
- package/src/internal/metric/pair.ts +0 -48
- package/src/internal/metric/polling.ts +0 -149
- package/src/internal/metric/registry.ts +0 -187
- package/src/internal/metric/state.ts +0 -290
- package/src/internal/metric.ts +0 -577
- package/src/internal/opCodes/cause.ts +0 -35
- package/src/internal/opCodes/channel.ts +0 -83
- package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
- package/src/internal/opCodes/channelMergeDecision.ts +0 -11
- package/src/internal/opCodes/channelMergeState.ts +0 -17
- package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
- package/src/internal/opCodes/channelState.ts +0 -23
- package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
- package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
- package/src/internal/opCodes/config.ts +0 -65
- package/src/internal/opCodes/configError.ts +0 -35
- package/src/internal/opCodes/continuation.ts +0 -11
- package/src/internal/opCodes/deferred.ts +0 -11
- package/src/internal/opCodes/effect.ts +0 -89
- package/src/internal/opCodes/layer.ts +0 -59
- package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
- package/src/internal/option.ts +0 -80
- package/src/internal/pool.ts +0 -432
- package/src/internal/pubsub.ts +0 -1762
- package/src/internal/query.ts +0 -204
- package/src/internal/queue.ts +0 -766
- package/src/internal/random.ts +0 -161
- package/src/internal/rateLimiter.ts +0 -93
- package/src/internal/rcMap.ts +0 -285
- package/src/internal/rcRef.ts +0 -192
- package/src/internal/redBlackTree/iterator.ts +0 -200
- package/src/internal/redBlackTree/node.ts +0 -68
- package/src/internal/redBlackTree.ts +0 -1245
- package/src/internal/redacted.ts +0 -73
- package/src/internal/ref.ts +0 -171
- package/src/internal/reloadable.ts +0 -140
- package/src/internal/request.ts +0 -177
- package/src/internal/resource.ts +0 -76
- package/src/internal/ringBuffer.ts +0 -68
- package/src/internal/runtime.ts +0 -558
- package/src/internal/runtimeFlags.ts +0 -188
- package/src/internal/runtimeFlagsPatch.ts +0 -103
- package/src/internal/schedule/decision.ts +0 -47
- package/src/internal/schedule/interval.ts +0 -101
- package/src/internal/schedule/intervals.ts +0 -180
- package/src/internal/schedule.ts +0 -2199
- package/src/internal/schema/errors.ts +0 -191
- package/src/internal/schema/schemaId.ts +0 -106
- package/src/internal/schema/util.ts +0 -50
- package/src/internal/scopedCache.ts +0 -644
- package/src/internal/scopedRef.ts +0 -118
- package/src/internal/secret.ts +0 -89
- package/src/internal/singleShotGen.ts +0 -35
- package/src/internal/sink.ts +0 -2120
- package/src/internal/stack.ts +0 -10
- package/src/internal/stm/core.ts +0 -817
- package/src/internal/stm/entry.ts +0 -59
- package/src/internal/stm/journal.ts +0 -123
- package/src/internal/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/opCodes/tryCommit.ts +0 -11
- package/src/internal/stm/stm.ts +0 -1453
- package/src/internal/stm/stmState.ts +0 -136
- package/src/internal/stm/tArray.ts +0 -550
- package/src/internal/stm/tDeferred.ts +0 -81
- package/src/internal/stm/tExit.ts +0 -190
- package/src/internal/stm/tMap.ts +0 -824
- package/src/internal/stm/tPriorityQueue.ts +0 -267
- package/src/internal/stm/tPubSub.ts +0 -551
- package/src/internal/stm/tQueue.ts +0 -393
- package/src/internal/stm/tRandom.ts +0 -140
- package/src/internal/stm/tReentrantLock.ts +0 -352
- package/src/internal/stm/tRef.ts +0 -195
- package/src/internal/stm/tSemaphore.ts +0 -113
- package/src/internal/stm/tSet.ts +0 -259
- package/src/internal/stm/tSubscriptionRef.ts +0 -286
- package/src/internal/stm/tryCommit.ts +0 -34
- package/src/internal/stm/txnId.ts +0 -14
- package/src/internal/stm/versioned.ts +0 -4
- package/src/internal/stream/debounceState.ts +0 -57
- package/src/internal/stream/emit.ts +0 -123
- package/src/internal/stream/haltStrategy.ts +0 -94
- package/src/internal/stream/handoff.ts +0 -187
- package/src/internal/stream/handoffSignal.ts +0 -59
- package/src/internal/stream/pull.ts +0 -34
- package/src/internal/stream/sinkEndReason.ts +0 -30
- package/src/internal/stream/zipAllState.ts +0 -88
- package/src/internal/stream/zipChunksState.ts +0 -56
- package/src/internal/stream.ts +0 -8801
- package/src/internal/string-utils.ts +0 -107
- package/src/internal/subscriptionRef.ts +0 -138
- package/src/internal/supervisor/patch.ts +0 -190
- package/src/internal/supervisor.ts +0 -303
- package/src/internal/synchronizedRef.ts +0 -114
- package/src/internal/take.ts +0 -199
- package/src/internal/testing/sleep.ts +0 -27
- package/src/internal/testing/suspendedWarningData.ts +0 -85
- package/src/internal/testing/warningData.ts +0 -94
- package/src/internal/tracer.ts +0 -293
- package/src/internal/trie.ts +0 -722
- package/src/internal/version.ts +0 -7
package/src/internal/runtime.ts
DELETED
|
@@ -1,558 +0,0 @@
|
|
|
1
|
-
import type * as ReadonlyArray from "../Array.js"
|
|
2
|
-
import type * as Cause from "../Cause.js"
|
|
3
|
-
import * as Context from "../Context.js"
|
|
4
|
-
import type * as Effect from "../Effect.js"
|
|
5
|
-
import { equals } from "../Equal.js"
|
|
6
|
-
import * as Exit from "../Exit.js"
|
|
7
|
-
import * as Fiber from "../Fiber.js"
|
|
8
|
-
import * as FiberId from "../FiberId.js"
|
|
9
|
-
import type * as FiberRef from "../FiberRef.js"
|
|
10
|
-
import * as FiberRefs from "../FiberRefs.js"
|
|
11
|
-
import { dual, pipe } from "../Function.js"
|
|
12
|
-
import * as Inspectable from "../Inspectable.js"
|
|
13
|
-
import * as Option from "../Option.js"
|
|
14
|
-
import { pipeArguments } from "../Pipeable.js"
|
|
15
|
-
import * as Predicate from "../Predicate.js"
|
|
16
|
-
import type * as Runtime from "../Runtime.js"
|
|
17
|
-
import type * as RuntimeFlags from "../RuntimeFlags.js"
|
|
18
|
-
import * as scheduler_ from "../Scheduler.js"
|
|
19
|
-
import * as scope_ from "../Scope.js"
|
|
20
|
-
import * as InternalCause from "./cause.js"
|
|
21
|
-
import * as core from "./core.js"
|
|
22
|
-
import * as executionStrategy from "./executionStrategy.js"
|
|
23
|
-
import * as FiberRuntime from "./fiberRuntime.js"
|
|
24
|
-
import * as fiberScope from "./fiberScope.js"
|
|
25
|
-
import * as OpCodes from "./opCodes/effect.js"
|
|
26
|
-
import * as runtimeFlags from "./runtimeFlags.js"
|
|
27
|
-
import * as supervisor_ from "./supervisor.js"
|
|
28
|
-
|
|
29
|
-
const makeDual = <Args extends Array<any>, Return>(
|
|
30
|
-
f: (runtime: Runtime.Runtime<never>, effect: Effect.Effect<any, any>, ...args: Args) => Return
|
|
31
|
-
): {
|
|
32
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>, ...args: Args) => Return
|
|
33
|
-
<R, A, E>(runtime: Runtime.Runtime<R>, effect: Effect.Effect<A, E, R>, ...args: Args): Return
|
|
34
|
-
} =>
|
|
35
|
-
function(this: any) {
|
|
36
|
-
if (arguments.length === 1) {
|
|
37
|
-
const runtime = arguments[0]
|
|
38
|
-
return (effect: any, ...args: Args) => f(runtime, effect, ...args)
|
|
39
|
-
}
|
|
40
|
-
return f.apply(this, arguments as any)
|
|
41
|
-
} as any
|
|
42
|
-
|
|
43
|
-
/** @internal */
|
|
44
|
-
export const unsafeFork: {
|
|
45
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(
|
|
46
|
-
effect: Effect.Effect<A, E, R>,
|
|
47
|
-
options?: Runtime.RunForkOptions | undefined
|
|
48
|
-
) => Fiber.RuntimeFiber<A, E>
|
|
49
|
-
<R, A, E>(
|
|
50
|
-
runtime: Runtime.Runtime<R>,
|
|
51
|
-
effect: Effect.Effect<A, E, R>,
|
|
52
|
-
options?: Runtime.RunForkOptions | undefined
|
|
53
|
-
): Fiber.RuntimeFiber<A, E>
|
|
54
|
-
} = makeDual(<R, A, E>(
|
|
55
|
-
runtime: Runtime.Runtime<R>,
|
|
56
|
-
self: Effect.Effect<A, E, R>,
|
|
57
|
-
options?: Runtime.RunForkOptions
|
|
58
|
-
): Fiber.RuntimeFiber<A, E> => {
|
|
59
|
-
const fiberId = FiberId.unsafeMake()
|
|
60
|
-
const fiberRefUpdates: ReadonlyArray.NonEmptyArray<
|
|
61
|
-
readonly [FiberRef.FiberRef<any>, ReadonlyArray.NonEmptyReadonlyArray<readonly [FiberId.Runtime, any]>]
|
|
62
|
-
> = [[core.currentContext, [[fiberId, runtime.context]]]]
|
|
63
|
-
|
|
64
|
-
if (options?.scheduler) {
|
|
65
|
-
fiberRefUpdates.push([scheduler_.currentScheduler, [[fiberId, options.scheduler]]])
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let fiberRefs = FiberRefs.updateManyAs(runtime.fiberRefs, {
|
|
69
|
-
entries: fiberRefUpdates,
|
|
70
|
-
forkAs: fiberId
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
if (options?.updateRefs) {
|
|
74
|
-
fiberRefs = options.updateRefs(fiberRefs, fiberId)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const fiberRuntime: FiberRuntime.FiberRuntime<A, E> = new FiberRuntime.FiberRuntime<A, E>(
|
|
78
|
-
fiberId,
|
|
79
|
-
fiberRefs,
|
|
80
|
-
runtime.runtimeFlags
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
let effect: Effect.Effect<A, E, R> = self
|
|
84
|
-
|
|
85
|
-
if (options?.scope) {
|
|
86
|
-
effect = core.flatMap(
|
|
87
|
-
scope_.fork(options.scope, executionStrategy.sequential),
|
|
88
|
-
(closeableScope) =>
|
|
89
|
-
core.zipRight(
|
|
90
|
-
core.scopeAddFinalizer(
|
|
91
|
-
closeableScope,
|
|
92
|
-
core.fiberIdWith((id) =>
|
|
93
|
-
equals(id, fiberRuntime.id()) ? core.void : core.interruptAsFiber(fiberRuntime, id)
|
|
94
|
-
)
|
|
95
|
-
),
|
|
96
|
-
core.onExit(self, (exit) => scope_.close(closeableScope, exit))
|
|
97
|
-
)
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const supervisor = fiberRuntime.currentSupervisor
|
|
102
|
-
|
|
103
|
-
// we can compare by reference here as _supervisor.none is wrapped with globalValue
|
|
104
|
-
if (supervisor !== supervisor_.none) {
|
|
105
|
-
supervisor.onStart(runtime.context, effect, Option.none(), fiberRuntime)
|
|
106
|
-
|
|
107
|
-
fiberRuntime.addObserver((exit) => supervisor.onEnd(exit, fiberRuntime))
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
fiberScope.globalScope.add(runtime.runtimeFlags, fiberRuntime)
|
|
111
|
-
|
|
112
|
-
// Only an explicit false will prevent immediate execution
|
|
113
|
-
if (options?.immediate === false) {
|
|
114
|
-
fiberRuntime.resume(effect)
|
|
115
|
-
} else {
|
|
116
|
-
fiberRuntime.start(effect)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return fiberRuntime
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
/** @internal */
|
|
123
|
-
export const unsafeRunCallback: {
|
|
124
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(
|
|
125
|
-
effect: Effect.Effect<A, E, R>,
|
|
126
|
-
options?: Runtime.RunCallbackOptions<A, E> | undefined
|
|
127
|
-
) => (fiberId?: FiberId.FiberId, options?: Runtime.RunCallbackOptions<A, E> | undefined) => void
|
|
128
|
-
<R, A, E>(
|
|
129
|
-
runtime: Runtime.Runtime<R>,
|
|
130
|
-
effect: Effect.Effect<A, E, R>,
|
|
131
|
-
options?: Runtime.RunCallbackOptions<A, E> | undefined
|
|
132
|
-
): (fiberId?: FiberId.FiberId, options?: Runtime.RunCallbackOptions<A, E> | undefined) => void
|
|
133
|
-
} = makeDual((
|
|
134
|
-
runtime,
|
|
135
|
-
effect,
|
|
136
|
-
options: Runtime.RunCallbackOptions<any, any> = {}
|
|
137
|
-
): (fiberId?: FiberId.FiberId, options?: Runtime.RunCallbackOptions<any, any> | undefined) => void => {
|
|
138
|
-
const fiberRuntime = unsafeFork(runtime, effect, options)
|
|
139
|
-
|
|
140
|
-
if (options.onExit) {
|
|
141
|
-
fiberRuntime.addObserver((exit) => {
|
|
142
|
-
options.onExit!(exit)
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return (id, cancelOptions) =>
|
|
147
|
-
unsafeRunCallback(runtime)(
|
|
148
|
-
pipe(fiberRuntime, Fiber.interruptAs(id ?? FiberId.none)),
|
|
149
|
-
{
|
|
150
|
-
...cancelOptions,
|
|
151
|
-
onExit: cancelOptions?.onExit
|
|
152
|
-
? (exit) => cancelOptions.onExit!(Exit.flatten(exit))
|
|
153
|
-
: undefined
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
/** @internal */
|
|
159
|
-
export const unsafeRunSync: {
|
|
160
|
-
<A, E, R>(runtime: Runtime.Runtime<R>, effect: Effect.Effect<A, E, R>): A
|
|
161
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>) => A
|
|
162
|
-
} = makeDual((runtime, effect) => {
|
|
163
|
-
const result = unsafeRunSyncExit(runtime)(effect)
|
|
164
|
-
if (result._tag === "Failure") {
|
|
165
|
-
throw fiberFailure(result.effect_instruction_i0)
|
|
166
|
-
}
|
|
167
|
-
return result.effect_instruction_i0
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
class AsyncFiberExceptionImpl<A, E = never> extends Error implements Runtime.AsyncFiberException<A, E> {
|
|
171
|
-
readonly _tag = "AsyncFiberException"
|
|
172
|
-
constructor(readonly fiber: Fiber.RuntimeFiber<A, E>) {
|
|
173
|
-
super(
|
|
174
|
-
`Fiber #${fiber.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`
|
|
175
|
-
)
|
|
176
|
-
this.name = this._tag
|
|
177
|
-
this.stack = this.message
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const asyncFiberException = <A, E>(fiber: Fiber.RuntimeFiber<A, E>): Runtime.AsyncFiberException<A, E> => {
|
|
182
|
-
const limit = Error.stackTraceLimit
|
|
183
|
-
Error.stackTraceLimit = 0
|
|
184
|
-
const error = new AsyncFiberExceptionImpl(fiber)
|
|
185
|
-
Error.stackTraceLimit = limit
|
|
186
|
-
return error
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** @internal */
|
|
190
|
-
export const isAsyncFiberException = (u: unknown): u is Runtime.AsyncFiberException<unknown, unknown> =>
|
|
191
|
-
Predicate.isTagged(u, "AsyncFiberException") && "fiber" in u
|
|
192
|
-
|
|
193
|
-
/** @internal */
|
|
194
|
-
export const FiberFailureId: Runtime.FiberFailureId = Symbol.for("effect/Runtime/FiberFailure") as any
|
|
195
|
-
/** @internal */
|
|
196
|
-
export const FiberFailureCauseId: Runtime.FiberFailureCauseId = Symbol.for(
|
|
197
|
-
"effect/Runtime/FiberFailure/Cause"
|
|
198
|
-
) as any
|
|
199
|
-
|
|
200
|
-
class FiberFailureImpl extends Error implements Runtime.FiberFailure {
|
|
201
|
-
readonly [FiberFailureId]: Runtime.FiberFailureId
|
|
202
|
-
readonly [FiberFailureCauseId]: Cause.Cause<unknown>
|
|
203
|
-
constructor(cause: Cause.Cause<unknown>) {
|
|
204
|
-
const head = InternalCause.prettyErrors(cause)[0]
|
|
205
|
-
|
|
206
|
-
super(head?.message || "An error has occurred")
|
|
207
|
-
this[FiberFailureId] = FiberFailureId
|
|
208
|
-
this[FiberFailureCauseId] = cause
|
|
209
|
-
|
|
210
|
-
this.name = head ? `(FiberFailure) ${head.name}` : "FiberFailure"
|
|
211
|
-
if (head?.stack) {
|
|
212
|
-
this.stack = head.stack
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
toJSON(): unknown {
|
|
217
|
-
return {
|
|
218
|
-
_id: "FiberFailure",
|
|
219
|
-
cause: this[FiberFailureCauseId].toJSON()
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
toString(): string {
|
|
224
|
-
return "(FiberFailure) " + InternalCause.pretty(this[FiberFailureCauseId], { renderErrorCause: true })
|
|
225
|
-
}
|
|
226
|
-
[Inspectable.NodeInspectSymbol](): unknown {
|
|
227
|
-
return this.toString()
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/** @internal */
|
|
232
|
-
export const fiberFailure = <E>(cause: Cause.Cause<E>): Runtime.FiberFailure => {
|
|
233
|
-
const limit = Error.stackTraceLimit
|
|
234
|
-
Error.stackTraceLimit = 0
|
|
235
|
-
const error = new FiberFailureImpl(cause)
|
|
236
|
-
Error.stackTraceLimit = limit
|
|
237
|
-
return error
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** @internal */
|
|
241
|
-
export const isFiberFailure = (u: unknown): u is Runtime.FiberFailure => Predicate.hasProperty(u, FiberFailureId)
|
|
242
|
-
|
|
243
|
-
const fastPath = <A, E, R>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E> | undefined => {
|
|
244
|
-
const op = effect as core.Primitive
|
|
245
|
-
switch (op._op) {
|
|
246
|
-
case "Failure":
|
|
247
|
-
case "Success": {
|
|
248
|
-
// @ts-expect-error
|
|
249
|
-
return op
|
|
250
|
-
}
|
|
251
|
-
case "Left": {
|
|
252
|
-
return core.exitFail(op.left)
|
|
253
|
-
}
|
|
254
|
-
case "Right": {
|
|
255
|
-
return core.exitSucceed(op.right)
|
|
256
|
-
}
|
|
257
|
-
case "Some": {
|
|
258
|
-
return core.exitSucceed(op.value)
|
|
259
|
-
}
|
|
260
|
-
case "None": {
|
|
261
|
-
// @ts-expect-error
|
|
262
|
-
return core.exitFail(new core.NoSuchElementException())
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/** @internal */
|
|
268
|
-
export const unsafeRunSyncExit: {
|
|
269
|
-
<A, E, R>(runtime: Runtime.Runtime<R>, effect: Effect.Effect<A, E, R>): Exit.Exit<A, E>
|
|
270
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, E>
|
|
271
|
-
} = makeDual((runtime, effect) => {
|
|
272
|
-
const op = fastPath(effect)
|
|
273
|
-
if (op) {
|
|
274
|
-
return op
|
|
275
|
-
}
|
|
276
|
-
const scheduler = new scheduler_.SyncScheduler()
|
|
277
|
-
const fiberRuntime = unsafeFork(runtime)(effect, { scheduler })
|
|
278
|
-
scheduler.flush()
|
|
279
|
-
const result = fiberRuntime.unsafePoll()
|
|
280
|
-
if (result) {
|
|
281
|
-
return result
|
|
282
|
-
}
|
|
283
|
-
return core.exitDie(core.capture(asyncFiberException(fiberRuntime), core.currentSpanFromFiber(fiberRuntime)))
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
/** @internal */
|
|
287
|
-
export const unsafeRunPromise: {
|
|
288
|
-
<R>(runtime: Runtime.Runtime<R>): <A, E>(
|
|
289
|
-
effect: Effect.Effect<A, E, R>,
|
|
290
|
-
options?: {
|
|
291
|
-
readonly signal?: AbortSignal | undefined
|
|
292
|
-
} | undefined
|
|
293
|
-
) => Promise<A>
|
|
294
|
-
<R, A, E>(
|
|
295
|
-
runtime: Runtime.Runtime<R>,
|
|
296
|
-
effect: Effect.Effect<A, E, R>,
|
|
297
|
-
options?: {
|
|
298
|
-
readonly signal?: AbortSignal | undefined
|
|
299
|
-
} | undefined
|
|
300
|
-
): Promise<A>
|
|
301
|
-
} = makeDual((
|
|
302
|
-
runtime,
|
|
303
|
-
effect,
|
|
304
|
-
options?: {
|
|
305
|
-
readonly signal?: AbortSignal | undefined
|
|
306
|
-
} | undefined
|
|
307
|
-
) =>
|
|
308
|
-
unsafeRunPromiseExit(runtime, effect, options).then((result) => {
|
|
309
|
-
switch (result._tag) {
|
|
310
|
-
case OpCodes.OP_SUCCESS: {
|
|
311
|
-
return result.effect_instruction_i0
|
|
312
|
-
}
|
|
313
|
-
case OpCodes.OP_FAILURE: {
|
|
314
|
-
throw fiberFailure(result.effect_instruction_i0)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
/** @internal */
|
|
321
|
-
export const unsafeRunPromiseExit: {
|
|
322
|
-
<R>(
|
|
323
|
-
runtime: Runtime.Runtime<R>
|
|
324
|
-
): <A, E>(
|
|
325
|
-
effect: Effect.Effect<A, E, R>,
|
|
326
|
-
options?: { readonly signal?: AbortSignal | undefined } | undefined
|
|
327
|
-
) => Promise<Exit.Exit<A, E>>
|
|
328
|
-
<R, A, E>(
|
|
329
|
-
runtime: Runtime.Runtime<R>,
|
|
330
|
-
effect: Effect.Effect<A, E, R>,
|
|
331
|
-
options?: { readonly signal?: AbortSignal | undefined } | undefined
|
|
332
|
-
): Promise<Exit.Exit<A, E>>
|
|
333
|
-
} = makeDual((
|
|
334
|
-
runtime,
|
|
335
|
-
effect,
|
|
336
|
-
options?: {
|
|
337
|
-
readonly signal?: AbortSignal | undefined
|
|
338
|
-
} | undefined
|
|
339
|
-
) =>
|
|
340
|
-
new Promise<Exit.Exit<any, any>>((resolve) => {
|
|
341
|
-
const op = fastPath(effect)
|
|
342
|
-
if (op) {
|
|
343
|
-
resolve(op)
|
|
344
|
-
}
|
|
345
|
-
const fiber = unsafeFork(runtime)(effect)
|
|
346
|
-
fiber.addObserver((exit) => {
|
|
347
|
-
resolve(exit)
|
|
348
|
-
})
|
|
349
|
-
if (options?.signal !== undefined) {
|
|
350
|
-
if (options.signal.aborted) {
|
|
351
|
-
fiber.unsafeInterruptAsFork(fiber.id())
|
|
352
|
-
} else {
|
|
353
|
-
options.signal.addEventListener("abort", () => {
|
|
354
|
-
fiber.unsafeInterruptAsFork(fiber.id())
|
|
355
|
-
}, { once: true })
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
})
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
/** @internal */
|
|
362
|
-
export class RuntimeImpl<in R> implements Runtime.Runtime<R> {
|
|
363
|
-
constructor(
|
|
364
|
-
readonly context: Context.Context<R>,
|
|
365
|
-
readonly runtimeFlags: RuntimeFlags.RuntimeFlags,
|
|
366
|
-
readonly fiberRefs: FiberRefs.FiberRefs
|
|
367
|
-
) {}
|
|
368
|
-
|
|
369
|
-
pipe() {
|
|
370
|
-
return pipeArguments(this, arguments)
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/** @internal */
|
|
375
|
-
export const make = <R>(
|
|
376
|
-
options: {
|
|
377
|
-
readonly context: Context.Context<R>
|
|
378
|
-
readonly runtimeFlags: RuntimeFlags.RuntimeFlags
|
|
379
|
-
readonly fiberRefs: FiberRefs.FiberRefs
|
|
380
|
-
}
|
|
381
|
-
): Runtime.Runtime<R> => new RuntimeImpl(options.context, options.runtimeFlags, options.fiberRefs)
|
|
382
|
-
|
|
383
|
-
/** @internal */
|
|
384
|
-
export const runtime = <R>(): Effect.Effect<Runtime.Runtime<R>, never, R> =>
|
|
385
|
-
core.withFiberRuntime((state, status) =>
|
|
386
|
-
core.succeed(
|
|
387
|
-
new RuntimeImpl<R>(
|
|
388
|
-
state.getFiberRef(core.currentContext as unknown as FiberRef.FiberRef<Context.Context<R>>),
|
|
389
|
-
status.runtimeFlags,
|
|
390
|
-
state.getFiberRefs()
|
|
391
|
-
)
|
|
392
|
-
)
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
/** @internal */
|
|
396
|
-
export const defaultRuntimeFlags: RuntimeFlags.RuntimeFlags = runtimeFlags.make(
|
|
397
|
-
runtimeFlags.Interruption,
|
|
398
|
-
runtimeFlags.CooperativeYielding,
|
|
399
|
-
runtimeFlags.RuntimeMetrics
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
/** @internal */
|
|
403
|
-
export const defaultRuntime = make({
|
|
404
|
-
context: Context.empty(),
|
|
405
|
-
runtimeFlags: defaultRuntimeFlags,
|
|
406
|
-
fiberRefs: FiberRefs.empty()
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
/** @internal */
|
|
410
|
-
export const updateRuntimeFlags: {
|
|
411
|
-
(
|
|
412
|
-
f: (flags: RuntimeFlags.RuntimeFlags) => RuntimeFlags.RuntimeFlags
|
|
413
|
-
): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
414
|
-
<R>(self: Runtime.Runtime<R>, f: (flags: RuntimeFlags.RuntimeFlags) => RuntimeFlags.RuntimeFlags): Runtime.Runtime<R>
|
|
415
|
-
} = dual(
|
|
416
|
-
2,
|
|
417
|
-
<R>(self: Runtime.Runtime<R>, f: (flags: RuntimeFlags.RuntimeFlags) => RuntimeFlags.RuntimeFlags) =>
|
|
418
|
-
make({
|
|
419
|
-
context: self.context,
|
|
420
|
-
runtimeFlags: f(self.runtimeFlags),
|
|
421
|
-
fiberRefs: self.fiberRefs
|
|
422
|
-
})
|
|
423
|
-
)
|
|
424
|
-
|
|
425
|
-
/** @internal */
|
|
426
|
-
export const disableRuntimeFlag: {
|
|
427
|
-
(flag: RuntimeFlags.RuntimeFlag): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
428
|
-
<R>(self: Runtime.Runtime<R>, flag: RuntimeFlags.RuntimeFlag): Runtime.Runtime<R>
|
|
429
|
-
} = dual(
|
|
430
|
-
2,
|
|
431
|
-
<R>(self: Runtime.Runtime<R>, flag: RuntimeFlags.RuntimeFlag) => updateRuntimeFlags(self, runtimeFlags.disable(flag))
|
|
432
|
-
)
|
|
433
|
-
|
|
434
|
-
/** @internal */
|
|
435
|
-
export const enableRuntimeFlag: {
|
|
436
|
-
(flag: RuntimeFlags.RuntimeFlag): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
437
|
-
<R>(self: Runtime.Runtime<R>, flag: RuntimeFlags.RuntimeFlag): Runtime.Runtime<R>
|
|
438
|
-
} = dual(
|
|
439
|
-
2,
|
|
440
|
-
<R>(self: Runtime.Runtime<R>, flag: RuntimeFlags.RuntimeFlag) => updateRuntimeFlags(self, runtimeFlags.enable(flag))
|
|
441
|
-
)
|
|
442
|
-
|
|
443
|
-
/** @internal */
|
|
444
|
-
export const updateContext: {
|
|
445
|
-
<R, R2>(f: (context: Context.Context<R>) => Context.Context<R2>): (self: Runtime.Runtime<R>) => Runtime.Runtime<R2>
|
|
446
|
-
<R, R2>(self: Runtime.Runtime<R>, f: (context: Context.Context<R>) => Context.Context<R2>): Runtime.Runtime<R2>
|
|
447
|
-
} = dual(
|
|
448
|
-
2,
|
|
449
|
-
<R, R2>(self: Runtime.Runtime<R>, f: (context: Context.Context<R>) => Context.Context<R2>) =>
|
|
450
|
-
make({
|
|
451
|
-
context: f(self.context),
|
|
452
|
-
runtimeFlags: self.runtimeFlags,
|
|
453
|
-
fiberRefs: self.fiberRefs
|
|
454
|
-
})
|
|
455
|
-
)
|
|
456
|
-
|
|
457
|
-
/** @internal */
|
|
458
|
-
export const provideService: {
|
|
459
|
-
<I, S>(tag: Context.Tag<I, S>, service: S): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R | I>
|
|
460
|
-
<R, I, S>(self: Runtime.Runtime<R>, tag: Context.Tag<I, S>, service: S): Runtime.Runtime<R | I>
|
|
461
|
-
} = dual(
|
|
462
|
-
3,
|
|
463
|
-
<R, I, S>(self: Runtime.Runtime<R>, tag: Context.Tag<I, S>, service: S) =>
|
|
464
|
-
updateContext(self, Context.add(tag, service))
|
|
465
|
-
)
|
|
466
|
-
|
|
467
|
-
/** @internal */
|
|
468
|
-
export const updateFiberRefs: {
|
|
469
|
-
(f: (fiberRefs: FiberRefs.FiberRefs) => FiberRefs.FiberRefs): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
470
|
-
<R>(self: Runtime.Runtime<R>, f: (fiberRefs: FiberRefs.FiberRefs) => FiberRefs.FiberRefs): Runtime.Runtime<R>
|
|
471
|
-
} = dual(
|
|
472
|
-
2,
|
|
473
|
-
<R>(self: Runtime.Runtime<R>, f: (fiberRefs: FiberRefs.FiberRefs) => FiberRefs.FiberRefs): Runtime.Runtime<R> =>
|
|
474
|
-
make({
|
|
475
|
-
context: self.context,
|
|
476
|
-
runtimeFlags: self.runtimeFlags,
|
|
477
|
-
fiberRefs: f(self.fiberRefs)
|
|
478
|
-
})
|
|
479
|
-
)
|
|
480
|
-
|
|
481
|
-
/** @internal */
|
|
482
|
-
export const setFiberRef: {
|
|
483
|
-
<A>(fiberRef: FiberRef.FiberRef<A>, value: A): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
484
|
-
<R, A>(self: Runtime.Runtime<R>, fiberRef: FiberRef.FiberRef<A>, value: A): Runtime.Runtime<R>
|
|
485
|
-
} = dual(
|
|
486
|
-
3,
|
|
487
|
-
<R, A>(self: Runtime.Runtime<R>, fiberRef: FiberRef.FiberRef<A>, value: A): Runtime.Runtime<R> =>
|
|
488
|
-
updateFiberRefs(
|
|
489
|
-
self,
|
|
490
|
-
FiberRefs.updateAs({
|
|
491
|
-
fiberId: FiberId.none,
|
|
492
|
-
fiberRef,
|
|
493
|
-
value
|
|
494
|
-
})
|
|
495
|
-
)
|
|
496
|
-
)
|
|
497
|
-
|
|
498
|
-
/** @internal */
|
|
499
|
-
export const deleteFiberRef: {
|
|
500
|
-
<A>(fiberRef: FiberRef.FiberRef<A>): <R>(self: Runtime.Runtime<R>) => Runtime.Runtime<R>
|
|
501
|
-
<R, A>(self: Runtime.Runtime<R>, fiberRef: FiberRef.FiberRef<A>): Runtime.Runtime<R>
|
|
502
|
-
} = dual(
|
|
503
|
-
2,
|
|
504
|
-
<R, A>(self: Runtime.Runtime<R>, fiberRef: FiberRef.FiberRef<A>): Runtime.Runtime<R> =>
|
|
505
|
-
updateFiberRefs(self, FiberRefs.delete(fiberRef))
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
/** @internal */
|
|
509
|
-
export const unsafeRunEffect = unsafeRunCallback(defaultRuntime)
|
|
510
|
-
|
|
511
|
-
/** @internal */
|
|
512
|
-
export const unsafeForkEffect = unsafeFork(defaultRuntime)
|
|
513
|
-
|
|
514
|
-
/** @internal */
|
|
515
|
-
export const unsafeRunPromiseEffect = unsafeRunPromise(defaultRuntime)
|
|
516
|
-
|
|
517
|
-
/** @internal */
|
|
518
|
-
export const unsafeRunPromiseExitEffect = unsafeRunPromiseExit(defaultRuntime)
|
|
519
|
-
|
|
520
|
-
/** @internal */
|
|
521
|
-
export const unsafeRunSyncEffect = unsafeRunSync(defaultRuntime)
|
|
522
|
-
|
|
523
|
-
/** @internal */
|
|
524
|
-
export const unsafeRunSyncExitEffect = unsafeRunSyncExit(defaultRuntime)
|
|
525
|
-
|
|
526
|
-
// circular with Effect
|
|
527
|
-
|
|
528
|
-
/** @internal */
|
|
529
|
-
export const asyncEffect = <A, E, R, R3, E2, R2>(
|
|
530
|
-
register: (
|
|
531
|
-
callback: (_: Effect.Effect<A, E, R>) => void
|
|
532
|
-
) => Effect.Effect<Effect.Effect<void, never, R3> | void, E2, R2>
|
|
533
|
-
): Effect.Effect<A, E | E2, R | R2 | R3> =>
|
|
534
|
-
core.suspend(() => {
|
|
535
|
-
let cleanup: Effect.Effect<void, never, R3> | void = undefined
|
|
536
|
-
return core.flatMap(
|
|
537
|
-
core.deferredMake<A, E | E2>(),
|
|
538
|
-
(deferred) =>
|
|
539
|
-
core.flatMap(runtime<R | R2 | R3>(), (runtime) =>
|
|
540
|
-
core.uninterruptibleMask((restore) =>
|
|
541
|
-
core.zipRight(
|
|
542
|
-
FiberRuntime.fork(restore(
|
|
543
|
-
core.matchCauseEffect(
|
|
544
|
-
register((cb) => unsafeRunCallback(runtime)(core.intoDeferred(cb, deferred))),
|
|
545
|
-
{
|
|
546
|
-
onFailure: (cause) => core.deferredFailCause(deferred, cause),
|
|
547
|
-
onSuccess: (cleanup_) => {
|
|
548
|
-
cleanup = cleanup_
|
|
549
|
-
return core.void
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
)
|
|
553
|
-
)),
|
|
554
|
-
restore(core.onInterrupt(core.deferredAwait(deferred), () => cleanup ?? core.void))
|
|
555
|
-
)
|
|
556
|
-
))
|
|
557
|
-
)
|
|
558
|
-
})
|