@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/fiber.ts
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import type * as Cause from "../Cause.js"
|
|
2
|
-
import * as Clock from "../Clock.js"
|
|
3
|
-
import type * as Effect from "../Effect.js"
|
|
4
|
-
import * as Either from "../Either.js"
|
|
5
|
-
import * as Exit from "../Exit.js"
|
|
6
|
-
import type * as Fiber from "../Fiber.js"
|
|
7
|
-
import * as FiberId from "../FiberId.js"
|
|
8
|
-
import * as FiberStatus from "../FiberStatus.js"
|
|
9
|
-
import { dual, pipe } from "../Function.js"
|
|
10
|
-
import * as HashSet from "../HashSet.js"
|
|
11
|
-
import * as number from "../Number.js"
|
|
12
|
-
import * as Option from "../Option.js"
|
|
13
|
-
import * as order from "../Order.js"
|
|
14
|
-
import { pipeArguments } from "../Pipeable.js"
|
|
15
|
-
import { hasProperty } from "../Predicate.js"
|
|
16
|
-
import * as core from "./core.js"
|
|
17
|
-
import * as effectable from "./effectable.js"
|
|
18
|
-
import * as fiberScope from "./fiberScope.js"
|
|
19
|
-
import * as runtimeFlags from "./runtimeFlags.js"
|
|
20
|
-
|
|
21
|
-
/** @internal */
|
|
22
|
-
const FiberSymbolKey = "effect/Fiber"
|
|
23
|
-
|
|
24
|
-
/** @internal */
|
|
25
|
-
export const FiberTypeId: Fiber.FiberTypeId = Symbol.for(
|
|
26
|
-
FiberSymbolKey
|
|
27
|
-
) as Fiber.FiberTypeId
|
|
28
|
-
|
|
29
|
-
/** @internal */
|
|
30
|
-
export const fiberVariance = {
|
|
31
|
-
/* c8 ignore next */
|
|
32
|
-
_E: (_: never) => _,
|
|
33
|
-
/* c8 ignore next */
|
|
34
|
-
_A: (_: never) => _
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** @internal */
|
|
38
|
-
const fiberProto = {
|
|
39
|
-
[FiberTypeId]: fiberVariance,
|
|
40
|
-
pipe() {
|
|
41
|
-
return pipeArguments(this, arguments)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @internal */
|
|
46
|
-
const RuntimeFiberSymbolKey = "effect/Fiber"
|
|
47
|
-
|
|
48
|
-
/** @internal */
|
|
49
|
-
export const RuntimeFiberTypeId: Fiber.RuntimeFiberTypeId = Symbol.for(
|
|
50
|
-
RuntimeFiberSymbolKey
|
|
51
|
-
) as Fiber.RuntimeFiberTypeId
|
|
52
|
-
|
|
53
|
-
/** @internal */
|
|
54
|
-
export const Order: order.Order<Fiber.RuntimeFiber<unknown, unknown>> = pipe(
|
|
55
|
-
order.tuple(number.Order, number.Order),
|
|
56
|
-
order.mapInput((fiber: Fiber.RuntimeFiber<unknown, unknown>) =>
|
|
57
|
-
[
|
|
58
|
-
(fiber.id() as FiberId.Runtime).startTimeMillis,
|
|
59
|
-
(fiber.id() as FiberId.Runtime).id
|
|
60
|
-
] as const
|
|
61
|
-
)
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
/** @internal */
|
|
65
|
-
export const isFiber = (u: unknown): u is Fiber.Fiber<unknown, unknown> => hasProperty(u, FiberTypeId)
|
|
66
|
-
|
|
67
|
-
/** @internal */
|
|
68
|
-
export const isRuntimeFiber = <A, E>(self: Fiber.Fiber<A, E>): self is Fiber.RuntimeFiber<A, E> =>
|
|
69
|
-
RuntimeFiberTypeId in self
|
|
70
|
-
|
|
71
|
-
/** @internal */
|
|
72
|
-
export const _await = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<Exit.Exit<A, E>> => self.await
|
|
73
|
-
|
|
74
|
-
/** @internal */
|
|
75
|
-
export const children = <A, E>(
|
|
76
|
-
self: Fiber.Fiber<A, E>
|
|
77
|
-
): Effect.Effect<Array<Fiber.RuntimeFiber<any, any>>> => self.children
|
|
78
|
-
|
|
79
|
-
/** @internal */
|
|
80
|
-
export const done = <A, E>(exit: Exit.Exit<A, E>): Fiber.Fiber<A, E> => {
|
|
81
|
-
const _fiber = {
|
|
82
|
-
...effectable.CommitPrototype,
|
|
83
|
-
commit() {
|
|
84
|
-
return join(this)
|
|
85
|
-
},
|
|
86
|
-
...fiberProto,
|
|
87
|
-
id: () => FiberId.none,
|
|
88
|
-
await: core.succeed(exit),
|
|
89
|
-
children: core.succeed([]),
|
|
90
|
-
inheritAll: core.void,
|
|
91
|
-
poll: core.succeed(Option.some(exit)),
|
|
92
|
-
interruptAsFork: () => core.void
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return _fiber
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** @internal */
|
|
99
|
-
export const dump = <A, E>(self: Fiber.RuntimeFiber<A, E>): Effect.Effect<Fiber.Fiber.Dump> =>
|
|
100
|
-
core.map(self.status, (status) => ({ id: self.id(), status }))
|
|
101
|
-
|
|
102
|
-
/** @internal */
|
|
103
|
-
export const dumpAll = (
|
|
104
|
-
fibers: Iterable<Fiber.RuntimeFiber<unknown, unknown>>
|
|
105
|
-
): Effect.Effect<Array<Fiber.Fiber.Dump>> => core.forEachSequential(fibers, dump)
|
|
106
|
-
|
|
107
|
-
/** @internal */
|
|
108
|
-
export const fail = <E>(error: E): Fiber.Fiber<never, E> => done(Exit.fail(error))
|
|
109
|
-
|
|
110
|
-
/** @internal */
|
|
111
|
-
export const failCause = <E>(cause: Cause.Cause<E>): Fiber.Fiber<never, E> => done(Exit.failCause(cause))
|
|
112
|
-
|
|
113
|
-
/** @internal */
|
|
114
|
-
export const fromEffect = <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<Fiber.Fiber<A, E>> =>
|
|
115
|
-
core.map(core.exit(effect), done)
|
|
116
|
-
|
|
117
|
-
/** @internal */
|
|
118
|
-
export const id = <A, E>(self: Fiber.Fiber<A, E>): FiberId.FiberId => self.id()
|
|
119
|
-
|
|
120
|
-
/** @internal */
|
|
121
|
-
export const inheritAll = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<void> => self.inheritAll
|
|
122
|
-
|
|
123
|
-
/** @internal */
|
|
124
|
-
export const interrupted = (fiberId: FiberId.FiberId): Fiber.Fiber<never> => done(Exit.interrupt(fiberId))
|
|
125
|
-
|
|
126
|
-
/** @internal */
|
|
127
|
-
export const interruptAll = (fibers: Iterable<Fiber.Fiber<any, any>>): Effect.Effect<void> =>
|
|
128
|
-
core.flatMap(core.fiberId, (fiberId) => pipe(fibers, interruptAllAs(fiberId)))
|
|
129
|
-
|
|
130
|
-
/** @internal */
|
|
131
|
-
export const interruptAllAs = dual<
|
|
132
|
-
(fiberId: FiberId.FiberId) => (fibers: Iterable<Fiber.Fiber<any, any>>) => Effect.Effect<void>,
|
|
133
|
-
(fibers: Iterable<Fiber.Fiber<any, any>>, fiberId: FiberId.FiberId) => Effect.Effect<void>
|
|
134
|
-
>(
|
|
135
|
-
2,
|
|
136
|
-
core.fnUntraced(function*(fibers, fiberId) {
|
|
137
|
-
for (const fiber of fibers) {
|
|
138
|
-
if (isRuntimeFiber(fiber)) {
|
|
139
|
-
fiber.unsafeInterruptAsFork(fiberId)
|
|
140
|
-
continue
|
|
141
|
-
}
|
|
142
|
-
yield* fiber.interruptAsFork(fiberId)
|
|
143
|
-
}
|
|
144
|
-
for (const fiber of fibers) {
|
|
145
|
-
if (isRuntimeFiber(fiber) && fiber.unsafePoll()) {
|
|
146
|
-
continue
|
|
147
|
-
}
|
|
148
|
-
yield* fiber.await
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
/** @internal */
|
|
154
|
-
export const interruptAsFork = dual<
|
|
155
|
-
(fiberId: FiberId.FiberId) => <A, E>(self: Fiber.Fiber<A, E>) => Effect.Effect<void>,
|
|
156
|
-
<A, E>(self: Fiber.Fiber<A, E>, fiberId: FiberId.FiberId) => Effect.Effect<void>
|
|
157
|
-
>(2, (self, fiberId) => self.interruptAsFork(fiberId))
|
|
158
|
-
|
|
159
|
-
/** @internal */
|
|
160
|
-
export const join = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<A, E> =>
|
|
161
|
-
core.zipLeft(core.flatten(self.await), self.inheritAll)
|
|
162
|
-
|
|
163
|
-
/** @internal */
|
|
164
|
-
export const map = dual<
|
|
165
|
-
<A, B>(f: (a: A) => B) => <E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<B, E>,
|
|
166
|
-
<A, E, B>(self: Fiber.Fiber<A, E>, f: (a: A) => B) => Fiber.Fiber<B, E>
|
|
167
|
-
>(2, (self, f) => mapEffect(self, (a) => core.sync(() => f(a))))
|
|
168
|
-
|
|
169
|
-
/** @internal */
|
|
170
|
-
export const mapEffect = dual<
|
|
171
|
-
<A, A2, E2>(f: (a: A) => Effect.Effect<A2, E2>) => <E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<A2, E | E2>,
|
|
172
|
-
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, f: (a: A) => Effect.Effect<A2, E2>) => Fiber.Fiber<A2, E | E2>
|
|
173
|
-
>(2, (self, f) => {
|
|
174
|
-
const _fiber = {
|
|
175
|
-
...effectable.CommitPrototype,
|
|
176
|
-
commit() {
|
|
177
|
-
return join(this)
|
|
178
|
-
},
|
|
179
|
-
...fiberProto,
|
|
180
|
-
id: () => self.id(),
|
|
181
|
-
await: core.flatMap(self.await, Exit.forEachEffect(f)),
|
|
182
|
-
children: self.children,
|
|
183
|
-
inheritAll: self.inheritAll,
|
|
184
|
-
poll: core.flatMap(self.poll, (result) => {
|
|
185
|
-
switch (result._tag) {
|
|
186
|
-
case "None":
|
|
187
|
-
return core.succeed(Option.none())
|
|
188
|
-
case "Some":
|
|
189
|
-
return pipe(
|
|
190
|
-
Exit.forEachEffect(result.value, f),
|
|
191
|
-
core.map(Option.some)
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
}),
|
|
195
|
-
interruptAsFork: (id: FiberId.FiberId) => self.interruptAsFork(id)
|
|
196
|
-
}
|
|
197
|
-
return _fiber
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
/** @internal */
|
|
201
|
-
export const mapFiber = dual<
|
|
202
|
-
<E, E2, A, B>(
|
|
203
|
-
f: (a: A) => Fiber.Fiber<B, E2>
|
|
204
|
-
) => (self: Fiber.Fiber<A, E>) => Effect.Effect<Fiber.Fiber<B, E | E2>>,
|
|
205
|
-
<A, E, E2, B>(
|
|
206
|
-
self: Fiber.Fiber<A, E>,
|
|
207
|
-
f: (a: A) => Fiber.Fiber<B, E2>
|
|
208
|
-
) => Effect.Effect<Fiber.Fiber<B, E | E2>>
|
|
209
|
-
>(2, <A, E, E2, B>(
|
|
210
|
-
self: Fiber.Fiber<A, E>,
|
|
211
|
-
f: (a: A) => Fiber.Fiber<B, E2>
|
|
212
|
-
) =>
|
|
213
|
-
core.map(
|
|
214
|
-
self.await,
|
|
215
|
-
Exit.match({
|
|
216
|
-
onFailure: (cause): Fiber.Fiber<B, E | E2> => failCause(cause),
|
|
217
|
-
onSuccess: (a) => f(a)
|
|
218
|
-
})
|
|
219
|
-
))
|
|
220
|
-
|
|
221
|
-
/** @internal */
|
|
222
|
-
export const match = dual<
|
|
223
|
-
<A, E, Z>(
|
|
224
|
-
options: {
|
|
225
|
-
readonly onFiber: (fiber: Fiber.Fiber<A, E>) => Z
|
|
226
|
-
readonly onRuntimeFiber: (fiber: Fiber.RuntimeFiber<A, E>) => Z
|
|
227
|
-
}
|
|
228
|
-
) => (self: Fiber.Fiber<A, E>) => Z,
|
|
229
|
-
<A, E, Z>(
|
|
230
|
-
self: Fiber.Fiber<A, E>,
|
|
231
|
-
options: {
|
|
232
|
-
readonly onFiber: (fiber: Fiber.Fiber<A, E>) => Z
|
|
233
|
-
readonly onRuntimeFiber: (fiber: Fiber.RuntimeFiber<A, E>) => Z
|
|
234
|
-
}
|
|
235
|
-
) => Z
|
|
236
|
-
>(2, (self, { onFiber, onRuntimeFiber }) => {
|
|
237
|
-
if (isRuntimeFiber(self)) {
|
|
238
|
-
return onRuntimeFiber(self)
|
|
239
|
-
}
|
|
240
|
-
return onFiber(self)
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
/** @internal */
|
|
244
|
-
const _never = {
|
|
245
|
-
...effectable.CommitPrototype,
|
|
246
|
-
commit() {
|
|
247
|
-
return join(this)
|
|
248
|
-
},
|
|
249
|
-
...fiberProto,
|
|
250
|
-
id: () => FiberId.none,
|
|
251
|
-
await: core.never,
|
|
252
|
-
children: core.succeed([]),
|
|
253
|
-
inheritAll: core.never,
|
|
254
|
-
poll: core.succeed(Option.none()),
|
|
255
|
-
interruptAsFork: () => core.never
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** @internal */
|
|
259
|
-
export const never: Fiber.Fiber<never> = _never
|
|
260
|
-
|
|
261
|
-
/** @internal */
|
|
262
|
-
export const orElse = dual<
|
|
263
|
-
<A2, E2>(that: Fiber.Fiber<A2, E2>) => <A, E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<A | A2, E | E2>,
|
|
264
|
-
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, that: Fiber.Fiber<A2, E2>) => Fiber.Fiber<A | A2, E | E2>
|
|
265
|
-
>(2, (self, that) => ({
|
|
266
|
-
...effectable.CommitPrototype,
|
|
267
|
-
commit() {
|
|
268
|
-
return join(this)
|
|
269
|
-
},
|
|
270
|
-
...fiberProto,
|
|
271
|
-
id: () => FiberId.getOrElse(self.id(), that.id()),
|
|
272
|
-
await: core.zipWith(
|
|
273
|
-
self.await,
|
|
274
|
-
that.await,
|
|
275
|
-
(exit1, exit2) => (Exit.isSuccess(exit1) ? exit1 : exit2)
|
|
276
|
-
),
|
|
277
|
-
children: self.children,
|
|
278
|
-
inheritAll: core.zipRight(that.inheritAll, self.inheritAll),
|
|
279
|
-
poll: core.zipWith(
|
|
280
|
-
self.poll,
|
|
281
|
-
that.poll,
|
|
282
|
-
(option1, option2) => {
|
|
283
|
-
switch (option1._tag) {
|
|
284
|
-
case "None": {
|
|
285
|
-
return Option.none()
|
|
286
|
-
}
|
|
287
|
-
case "Some": {
|
|
288
|
-
return Exit.isSuccess(option1.value) ? option1 : option2
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
),
|
|
293
|
-
interruptAsFork: (id) =>
|
|
294
|
-
pipe(
|
|
295
|
-
core.interruptAsFiber(self, id),
|
|
296
|
-
core.zipRight(pipe(that, core.interruptAsFiber(id))),
|
|
297
|
-
core.asVoid
|
|
298
|
-
)
|
|
299
|
-
}))
|
|
300
|
-
|
|
301
|
-
/** @internal */
|
|
302
|
-
export const orElseEither = dual<
|
|
303
|
-
<A2, E2>(that: Fiber.Fiber<A2, E2>) => <A, E>(self: Fiber.Fiber<A, E>) => Fiber.Fiber<Either.Either<A2, A>, E | E2>,
|
|
304
|
-
<A, E, A2, E2>(self: Fiber.Fiber<A, E>, that: Fiber.Fiber<A2, E2>) => Fiber.Fiber<Either.Either<A2, A>, E | E2>
|
|
305
|
-
>(2, (self, that) => orElse(map(self, Either.left), map(that, Either.right)))
|
|
306
|
-
|
|
307
|
-
/** @internal */
|
|
308
|
-
export const poll = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<Option.Option<Exit.Exit<A, E>>> => self.poll
|
|
309
|
-
|
|
310
|
-
// forked from https://github.com/sindresorhus/parse-ms/blob/4da2ffbdba02c6e288c08236695bdece0adca173/index.js
|
|
311
|
-
// MIT License
|
|
312
|
-
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
313
|
-
/** @internal */
|
|
314
|
-
const parseMs = (milliseconds: number) => {
|
|
315
|
-
const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil
|
|
316
|
-
return {
|
|
317
|
-
days: roundTowardsZero(milliseconds / 86400000),
|
|
318
|
-
hours: roundTowardsZero(milliseconds / 3600000) % 24,
|
|
319
|
-
minutes: roundTowardsZero(milliseconds / 60000) % 60,
|
|
320
|
-
seconds: roundTowardsZero(milliseconds / 1000) % 60,
|
|
321
|
-
milliseconds: roundTowardsZero(milliseconds) % 1000,
|
|
322
|
-
microseconds: roundTowardsZero(milliseconds * 1000) % 1000,
|
|
323
|
-
nanoseconds: roundTowardsZero(milliseconds * 1e6) % 1000
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/** @internal */
|
|
328
|
-
const renderStatus = (status: FiberStatus.FiberStatus): string => {
|
|
329
|
-
if (FiberStatus.isDone(status)) {
|
|
330
|
-
return "Done"
|
|
331
|
-
}
|
|
332
|
-
if (FiberStatus.isRunning(status)) {
|
|
333
|
-
return "Running"
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const isInterruptible = runtimeFlags.interruptible(status.runtimeFlags) ?
|
|
337
|
-
"interruptible" :
|
|
338
|
-
"uninterruptible"
|
|
339
|
-
return `Suspended(${isInterruptible})`
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/** @internal */
|
|
343
|
-
export const pretty = <A, E>(self: Fiber.RuntimeFiber<A, E>): Effect.Effect<string> =>
|
|
344
|
-
core.flatMap(Clock.currentTimeMillis, (now) =>
|
|
345
|
-
core.map(dump(self), (dump) => {
|
|
346
|
-
const time = now - dump.id.startTimeMillis
|
|
347
|
-
const { days, hours, milliseconds, minutes, seconds } = parseMs(time)
|
|
348
|
-
const lifeMsg = (days === 0 ? "" : `${days}d`) +
|
|
349
|
-
(days === 0 && hours === 0 ? "" : `${hours}h`) +
|
|
350
|
-
(days === 0 && hours === 0 && minutes === 0 ? "" : `${minutes}m`) +
|
|
351
|
-
(days === 0 && hours === 0 && minutes === 0 && seconds === 0 ? "" : `${seconds}s`) +
|
|
352
|
-
`${milliseconds}ms`
|
|
353
|
-
const waitMsg = FiberStatus.isSuspended(dump.status) ?
|
|
354
|
-
(() => {
|
|
355
|
-
const ids = FiberId.ids(dump.status.blockingOn)
|
|
356
|
-
return HashSet.size(ids) > 0
|
|
357
|
-
? `waiting on ` + Array.from(ids).map((id) => `${id}`).join(", ")
|
|
358
|
-
: ""
|
|
359
|
-
})() :
|
|
360
|
-
""
|
|
361
|
-
const statusMsg = renderStatus(dump.status)
|
|
362
|
-
return `[Fiber](#${dump.id.id}) (${lifeMsg}) ${waitMsg}\n Status: ${statusMsg}`
|
|
363
|
-
}))
|
|
364
|
-
|
|
365
|
-
/** @internal */
|
|
366
|
-
export const unsafeRoots = (): Array<Fiber.RuntimeFiber<any, any>> => Array.from(fiberScope.globalScope.roots)
|
|
367
|
-
|
|
368
|
-
/** @internal */
|
|
369
|
-
export const roots: Effect.Effect<Array<Fiber.RuntimeFiber<any, any>>> = core.sync(unsafeRoots)
|
|
370
|
-
|
|
371
|
-
/** @internal */
|
|
372
|
-
export const status = <A, E>(self: Fiber.RuntimeFiber<A, E>): Effect.Effect<FiberStatus.FiberStatus> => self.status
|
|
373
|
-
|
|
374
|
-
/** @internal */
|
|
375
|
-
export const succeed = <A>(value: A): Fiber.Fiber<A> => done(Exit.succeed(value))
|
|
376
|
-
|
|
377
|
-
const void_: Fiber.Fiber<void> = succeed(void 0)
|
|
378
|
-
export {
|
|
379
|
-
/** @internal */
|
|
380
|
-
void_ as void
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/** @internal */
|
|
384
|
-
export const currentFiberURI = "effect/FiberCurrent"
|
|
385
|
-
|
|
386
|
-
/** @internal */
|
|
387
|
-
export const getCurrentFiber = (): Option.Option<Fiber.RuntimeFiber<any, any>> =>
|
|
388
|
-
Option.fromNullable((globalThis as any)[currentFiberURI])
|
package/src/internal/fiberId.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import * as Equal from "../Equal.js"
|
|
2
|
-
import type * as FiberId from "../FiberId.js"
|
|
3
|
-
import { dual, pipe } from "../Function.js"
|
|
4
|
-
import { globalValue } from "../GlobalValue.js"
|
|
5
|
-
import * as Hash from "../Hash.js"
|
|
6
|
-
import * as HashSet from "../HashSet.js"
|
|
7
|
-
import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
|
|
8
|
-
import * as MutableRef from "../MutableRef.js"
|
|
9
|
-
import * as Option from "../Option.js"
|
|
10
|
-
import { hasProperty } from "../Predicate.js"
|
|
11
|
-
|
|
12
|
-
/** @internal */
|
|
13
|
-
const FiberIdSymbolKey = "effect/FiberId"
|
|
14
|
-
|
|
15
|
-
/** @internal */
|
|
16
|
-
export const FiberIdTypeId: FiberId.FiberIdTypeId = Symbol.for(
|
|
17
|
-
FiberIdSymbolKey
|
|
18
|
-
) as FiberId.FiberIdTypeId
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
const OP_NONE = "None" as const
|
|
22
|
-
|
|
23
|
-
/** @internal */
|
|
24
|
-
export type OP_NONE = typeof OP_NONE
|
|
25
|
-
|
|
26
|
-
/** @internal */
|
|
27
|
-
const OP_RUNTIME = "Runtime" as const
|
|
28
|
-
|
|
29
|
-
/** @internal */
|
|
30
|
-
export type OP_RUNTIME = typeof OP_RUNTIME
|
|
31
|
-
|
|
32
|
-
/** @internal */
|
|
33
|
-
const OP_COMPOSITE = "Composite" as const
|
|
34
|
-
|
|
35
|
-
/** @internal */
|
|
36
|
-
export type OP_COMPOSITE = typeof OP_COMPOSITE
|
|
37
|
-
|
|
38
|
-
const emptyHash = Hash.string(`${FiberIdSymbolKey}-${OP_NONE}`)
|
|
39
|
-
|
|
40
|
-
/** @internal */
|
|
41
|
-
class None implements FiberId.None {
|
|
42
|
-
readonly [FiberIdTypeId]: FiberId.FiberIdTypeId = FiberIdTypeId
|
|
43
|
-
readonly _tag = OP_NONE
|
|
44
|
-
readonly id = -1
|
|
45
|
-
readonly startTimeMillis = -1;
|
|
46
|
-
[Hash.symbol](): number {
|
|
47
|
-
return emptyHash
|
|
48
|
-
}
|
|
49
|
-
[Equal.symbol](that: unknown): boolean {
|
|
50
|
-
return isFiberId(that) && that._tag === OP_NONE
|
|
51
|
-
}
|
|
52
|
-
toString() {
|
|
53
|
-
return format(this.toJSON())
|
|
54
|
-
}
|
|
55
|
-
toJSON() {
|
|
56
|
-
return {
|
|
57
|
-
_id: "FiberId",
|
|
58
|
-
_tag: this._tag
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
[NodeInspectSymbol]() {
|
|
62
|
-
return this.toJSON()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** @internal */
|
|
67
|
-
class Runtime implements FiberId.Runtime {
|
|
68
|
-
readonly [FiberIdTypeId]: FiberId.FiberIdTypeId = FiberIdTypeId
|
|
69
|
-
readonly _tag = OP_RUNTIME
|
|
70
|
-
constructor(
|
|
71
|
-
readonly id: number,
|
|
72
|
-
readonly startTimeMillis: number
|
|
73
|
-
) {}
|
|
74
|
-
[Hash.symbol](): number {
|
|
75
|
-
return Hash.cached(this, Hash.string(`${FiberIdSymbolKey}-${this._tag}-${this.id}-${this.startTimeMillis}`))
|
|
76
|
-
}
|
|
77
|
-
[Equal.symbol](that: unknown): boolean {
|
|
78
|
-
return isFiberId(that) &&
|
|
79
|
-
that._tag === OP_RUNTIME &&
|
|
80
|
-
this.id === that.id &&
|
|
81
|
-
this.startTimeMillis === that.startTimeMillis
|
|
82
|
-
}
|
|
83
|
-
toString() {
|
|
84
|
-
return format(this.toJSON())
|
|
85
|
-
}
|
|
86
|
-
toJSON() {
|
|
87
|
-
return {
|
|
88
|
-
_id: "FiberId",
|
|
89
|
-
_tag: this._tag,
|
|
90
|
-
id: this.id,
|
|
91
|
-
startTimeMillis: this.startTimeMillis
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
[NodeInspectSymbol]() {
|
|
95
|
-
return this.toJSON()
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** @internal */
|
|
100
|
-
class Composite implements FiberId.Composite {
|
|
101
|
-
readonly [FiberIdTypeId]: FiberId.FiberIdTypeId = FiberIdTypeId
|
|
102
|
-
readonly _tag = OP_COMPOSITE
|
|
103
|
-
constructor(
|
|
104
|
-
readonly left: FiberId.FiberId,
|
|
105
|
-
readonly right: FiberId.FiberId
|
|
106
|
-
) {
|
|
107
|
-
}
|
|
108
|
-
_hash: number | undefined;
|
|
109
|
-
[Hash.symbol](): number {
|
|
110
|
-
return pipe(
|
|
111
|
-
Hash.string(`${FiberIdSymbolKey}-${this._tag}`),
|
|
112
|
-
Hash.combine(Hash.hash(this.left)),
|
|
113
|
-
Hash.combine(Hash.hash(this.right)),
|
|
114
|
-
Hash.cached(this)
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
[Equal.symbol](that: unknown): boolean {
|
|
118
|
-
return isFiberId(that) &&
|
|
119
|
-
that._tag === OP_COMPOSITE &&
|
|
120
|
-
Equal.equals(this.left, that.left) &&
|
|
121
|
-
Equal.equals(this.right, that.right)
|
|
122
|
-
}
|
|
123
|
-
toString() {
|
|
124
|
-
return format(this.toJSON())
|
|
125
|
-
}
|
|
126
|
-
toJSON() {
|
|
127
|
-
return {
|
|
128
|
-
_id: "FiberId",
|
|
129
|
-
_tag: this._tag,
|
|
130
|
-
left: toJSON(this.left),
|
|
131
|
-
right: toJSON(this.right)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
[NodeInspectSymbol]() {
|
|
135
|
-
return this.toJSON()
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/** @internal */
|
|
140
|
-
export const none: FiberId.None = new None()
|
|
141
|
-
|
|
142
|
-
/** @internal */
|
|
143
|
-
export const runtime = (id: number, startTimeMillis: number): FiberId.Runtime => {
|
|
144
|
-
return new Runtime(id, startTimeMillis)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** @internal */
|
|
148
|
-
export const composite = (left: FiberId.FiberId, right: FiberId.FiberId): FiberId.Composite => {
|
|
149
|
-
return new Composite(left, right)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** @internal */
|
|
153
|
-
export const isFiberId = (self: unknown): self is FiberId.FiberId => hasProperty(self, FiberIdTypeId)
|
|
154
|
-
|
|
155
|
-
/** @internal */
|
|
156
|
-
export const isNone = (self: FiberId.FiberId): self is FiberId.None => {
|
|
157
|
-
return self._tag === OP_NONE || pipe(toSet(self), HashSet.every((id) => isNone(id)))
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** @internal */
|
|
161
|
-
export const isRuntime = (self: FiberId.FiberId): self is FiberId.Runtime => {
|
|
162
|
-
return self._tag === OP_RUNTIME
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** @internal */
|
|
166
|
-
export const isComposite = (self: FiberId.FiberId): self is FiberId.Composite => {
|
|
167
|
-
return self._tag === OP_COMPOSITE
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/** @internal */
|
|
171
|
-
export const combine = dual<
|
|
172
|
-
(that: FiberId.FiberId) => (self: FiberId.FiberId) => FiberId.FiberId,
|
|
173
|
-
(self: FiberId.FiberId, that: FiberId.FiberId) => FiberId.FiberId
|
|
174
|
-
>(2, (self, that) => {
|
|
175
|
-
if (self._tag === OP_NONE) {
|
|
176
|
-
return that
|
|
177
|
-
}
|
|
178
|
-
if (that._tag === OP_NONE) {
|
|
179
|
-
return self
|
|
180
|
-
}
|
|
181
|
-
return new Composite(self, that)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
/** @internal */
|
|
185
|
-
export const combineAll = (fiberIds: HashSet.HashSet<FiberId.FiberId>): FiberId.FiberId => {
|
|
186
|
-
return pipe(fiberIds, HashSet.reduce(none as FiberId.FiberId, (a, b) => combine(b)(a)))
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** @internal */
|
|
190
|
-
export const getOrElse = dual<
|
|
191
|
-
(that: FiberId.FiberId) => (self: FiberId.FiberId) => FiberId.FiberId,
|
|
192
|
-
(self: FiberId.FiberId, that: FiberId.FiberId) => FiberId.FiberId
|
|
193
|
-
>(2, (self, that) => isNone(self) ? that : self)
|
|
194
|
-
|
|
195
|
-
/** @internal */
|
|
196
|
-
export const ids = (self: FiberId.FiberId): HashSet.HashSet<number> => {
|
|
197
|
-
switch (self._tag) {
|
|
198
|
-
case OP_NONE: {
|
|
199
|
-
return HashSet.empty()
|
|
200
|
-
}
|
|
201
|
-
case OP_RUNTIME: {
|
|
202
|
-
return HashSet.make(self.id)
|
|
203
|
-
}
|
|
204
|
-
case OP_COMPOSITE: {
|
|
205
|
-
return pipe(ids(self.left), HashSet.union(ids(self.right)))
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const _fiberCounter = globalValue(
|
|
211
|
-
Symbol.for("effect/Fiber/Id/_fiberCounter"),
|
|
212
|
-
() => MutableRef.make(0)
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
/** @internal */
|
|
216
|
-
export const make = (id: number, startTimeSeconds: number): FiberId.FiberId => {
|
|
217
|
-
return new Runtime(id, startTimeSeconds)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** @internal */
|
|
221
|
-
export const threadName = (self: FiberId.FiberId): string => {
|
|
222
|
-
const identifiers = Array.from(ids(self)).map((n) => `#${n}`).join(",")
|
|
223
|
-
return identifiers
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** @internal */
|
|
227
|
-
export const toOption = (self: FiberId.FiberId): Option.Option<FiberId.FiberId> => {
|
|
228
|
-
const fiberIds = toSet(self)
|
|
229
|
-
if (HashSet.size(fiberIds) === 0) {
|
|
230
|
-
return Option.none()
|
|
231
|
-
}
|
|
232
|
-
let first = true
|
|
233
|
-
let acc: FiberId.FiberId
|
|
234
|
-
for (const fiberId of fiberIds) {
|
|
235
|
-
if (first) {
|
|
236
|
-
acc = fiberId
|
|
237
|
-
first = false
|
|
238
|
-
} else {
|
|
239
|
-
// @ts-expect-error
|
|
240
|
-
acc = pipe(acc, combine(fiberId))
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// @ts-expect-error
|
|
244
|
-
return Option.some(acc)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** @internal */
|
|
248
|
-
export const toSet = (self: FiberId.FiberId): HashSet.HashSet<FiberId.Runtime> => {
|
|
249
|
-
switch (self._tag) {
|
|
250
|
-
case OP_NONE: {
|
|
251
|
-
return HashSet.empty()
|
|
252
|
-
}
|
|
253
|
-
case OP_RUNTIME: {
|
|
254
|
-
return HashSet.make(self)
|
|
255
|
-
}
|
|
256
|
-
case OP_COMPOSITE: {
|
|
257
|
-
return pipe(toSet(self.left), HashSet.union(toSet(self.right)))
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** @internal */
|
|
263
|
-
export const unsafeMake = (): FiberId.Runtime => {
|
|
264
|
-
const id = MutableRef.get(_fiberCounter)
|
|
265
|
-
pipe(_fiberCounter, MutableRef.set(id + 1))
|
|
266
|
-
return new Runtime(id, Date.now())
|
|
267
|
-
}
|