effect 2.4.13 → 2.4.15
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/Config.js +8 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Duration.js +6 -2
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Request.js.map +1 -1
- package/dist/cjs/internal/config.js +11 -1
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +45 -7
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/query.js +14 -14
- package/dist/cjs/internal/query.js.map +1 -1
- package/dist/cjs/internal/request.js +1 -0
- package/dist/cjs/internal/request.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Config.d.ts +8 -0
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +4 -0
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Request.d.ts +1 -0
- package/dist/dts/Request.d.ts.map +1 -1
- package/dist/esm/Config.js +7 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Duration.js +6 -2
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Request.js.map +1 -1
- package/dist/esm/internal/config.js +9 -0
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +45 -7
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/query.js +14 -14
- package/dist/esm/internal/query.js.map +1 -1
- package/dist/esm/internal/request.js +1 -0
- package/dist/esm/internal/request.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Config.ts +9 -0
- package/src/Duration.ts +7 -2
- package/src/Request.ts +2 -1
- package/src/internal/config.ts +10 -0
- package/src/internal/fiberRuntime.ts +55 -14
- package/src/internal/query.ts +53 -50
- package/src/internal/request.ts +1 -0
- package/src/internal/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":["dual","hasProperty","completedRequestMap","core","StructuralPrototype","RequestSymbolKey","RequestTypeId","Symbol","for","requestVariance","_E","_","_A","RequestPrototype","isRequest","u","of","args","Object","assign","create","tagged","tag","request","_tag","Class","prototype","TaggedClass","complete","self","result","fiberRefGetWith","currentRequestMap","map","sync","has","entry","get","state","completed","deferredUnsafeDone","completeEffect","effect","matchEffect","onFailure","error","exitFail","onSuccess","value","exitSucceed","fail","failCause","cause","exitFailCause","succeed","Listeners","count","observers","Set","addObserver","f","add","removeObserver","delete","increment","forEach","decrement","filterOutCompleted","requests","filter"],"sources":["../../../src/internal/request.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,IAAI,QAAQ,gBAAgB;AACrC,SAASC,WAAW,QAAQ,iBAAiB;AAG7C,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAC/D,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,mBAAmB,QAAQ,iBAAiB;AAErD;AACA,MAAMC,gBAAgB,GAAG,gBAAgB;AAEzC;AACA,OAAO,MAAMC,aAAa,gBAA0BC,MAAM,CAACC,GAAG,CAC5DH,gBAAgB,CACQ;AAE1B,MAAMI,eAAe,GAAG;EACtB;EACAC,EAAE,EAAGC,CAAQ,IAAKA,CAAC;EACnB;EACAC,EAAE,EAAGD,CAAQ,IAAKA;CACnB;AAED,MAAME,gBAAgB,GAAG;EACvB,GAAGT,mBAAmB;EACtB,CAACE,aAAa,GAAGG;CAClB;AAED;AACA,OAAO,MAAMK,SAAS,GAAIC,CAAU,IAA6Cd,WAAW,CAACc,CAAC,EAAET,aAAa,CAAC;AAE9G;AACA,OAAO,MAAMU,EAAE,GAAGA,CAAA,KAA4EC,IAAI,IAChGC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACP,gBAAgB,CAAC,EAAEI,IAAI,CAAC;AAEtD;AACA,OAAO,MAAMI,MAAM,GACjBC,GAAc,I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AACwC,WAAW,CAACD,MAAM,EAAE;EACvBE,SAAS,EAAGC,KAAK,IAAKjB,QAAQ,CAACC,IAAI,EAAE1B,IAAI,CAAC2C,QAAQ,CAACD,KAAK,CAAQ,CAAC;EACjEE,SAAS,EAAGC,KAAK,IAAKpB,QAAQ,CAACC,IAAI,EAAE1B,IAAI,CAAC8C,WAAW,CAACD,KAAK,CAAQ;CACpE,CAAC,CAAC;AAEL;AACA,OAAO,MAAME,IAAI,gBAAGlD,IAAI,CAQtB,CAAC,EAAE,CAAC6B,IAAI,EAAEgB,KAAK,KAAKjB,QAAQ,CAACC,IAAI,EAAE1B,IAAI,CAAC2C,QAAQ,CAACD,KAAK,CAAQ,CAAC,CAAC;AAElE;AACA,OAAO,MAAMM,SAAS,gBAAGnD,IAAI,CAQ3B,CAAC,EAAE,CAAC6B,IAAI,EAAEuB,KAAK,KAAKxB,QAAQ,CAACC,IAAI,EAAE1B,IAAI,CAACkD,aAAa,CAACD,KAAK,CAAQ,CAAC,CAAC;AAEvE;AACA,OAAO,MAAME,OAAO,gBAAGtD,IAAI,CAQzB,CAAC,EAAE,CAAC6B,IAAI,EAAEmB,KAAK,KAAKpB,QAAQ,CAACC,IAAI,EAAE1B,IAAI,CAAC8C,WAAW,CAACD,KAAK,CAAQ,CAAC,CAAC;AAErE;AACA,OAAM,MAAOO,SAAS;EACpBC,KAAK,GAAG,CAAC;EACTC,SAAS,GAAiC,IAAIC,GAAG,EAAE;EACnDC,WAAWA,CAACC,CAA0B;IACpC,IAAI,
|
|
1
|
+
{"version":3,"file":"request.js","names":["dual","hasProperty","completedRequestMap","core","StructuralPrototype","RequestSymbolKey","RequestTypeId","Symbol","for","requestVariance","_E","_","_A","RequestPrototype","isRequest","u","of","args","Object","assign","create","tagged","tag","request","_tag","Class","prototype","TaggedClass","complete","self","result","fiberRefGetWith","currentRequestMap","map","sync","has","entry","get","state","completed","deferredUnsafeDone","completeEffect","effect","matchEffect","onFailure","error","exitFail","onSuccess","value","exitSucceed","fail","failCause","cause","exitFailCause","succeed","Listeners","count","observers","Set","interrupted","addObserver","f","add","removeObserver","delete","increment","forEach","decrement","filterOutCompleted","requests","filter"],"sources":["../../../src/internal/request.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,IAAI,QAAQ,gBAAgB;AACrC,SAASC,WAAW,QAAQ,iBAAiB;AAG7C,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAC/D,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,mBAAmB,QAAQ,iBAAiB;AAErD;AACA,MAAMC,gBAAgB,GAAG,gBAAgB;AAEzC;AACA,OAAO,MAAMC,aAAa,gBAA0BC,MAAM,CAACC,GAAG,CAC5DH,gBAAgB,CACQ;AAE1B,MAAMI,eAAe,GAAG;EACtB;EACAC,EAAE,EAAGC,CAAQ,IAAKA,CAAC;EACnB;EACAC,EAAE,EAAGD,CAAQ,IAAKA;CACnB;AAED,MAAME,gBAAgB,GAAG;EACvB,GAAGT,mBAAmB;EACtB,CAACE,aAAa,GAAGG;CAClB;AAED;AACA,OAAO,MAAMK,SAAS,GAAIC,CAAU,IAA6Cd,WAAW,CAACc,CAAC,EAAET,aAAa,CAAC;AAE9G;AACA,OAAO,MAAMU,EAAE,GAAGA,CAAA,KAA4EC,IAAI,IAChGC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACP,gBAAgB,CAAC,EAAEI,IAAI,CAAC;AAEtD;AACA,OAAO,MAAMI,MAAM,GACjBC,GAAc,IAEfL,IAAI,IAAI;EACP,MAAMM,OAAO,GAAGL,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAACP,gBAAgB,CAAC,EAAEI,IAAI,CAAC;EACpEM,OAAO,CAACC,IAAI,GAAGF,GAAG;EAClB,OAAOC,OAAO;AAChB,CAAC;AAED;AACA,OAAO,MAAME,KAAK,gBAGoC;EACpD,SAASA,KAAKA,CAAYR,IAAS;IACjC,IAAIA,IAAI,EAAE;MACRC,MAAM,C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G,IACF9B,IAAI,CAACmD,OAAO,CACVe,QAAQ,CAACC,MAAM,CAAE/C,OAAO,IAAK,EAAEU,GAAG,CAACI,GAAG,CAACd,OAAO,CAAC,EAAEe,KAAK,CAACC,SAAS,KAAK,IAAI,CAAC,CAAC,CAC5E,CACJ","ignoreList":[]}
|
package/package.json
CHANGED
package/src/Config.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as Chunk from "./Chunk.js"
|
|
5
5
|
import type * as ConfigError from "./ConfigError.js"
|
|
6
|
+
import type * as Duration from "./Duration.js"
|
|
6
7
|
import type * as Effect from "./Effect.js"
|
|
7
8
|
import type * as Either from "./Either.js"
|
|
8
9
|
import type { LazyArg } from "./Function.js"
|
|
@@ -180,6 +181,14 @@ export const literal: <Literals extends ReadonlyArray<LiteralValue>>(...literals
|
|
|
180
181
|
*/
|
|
181
182
|
export const logLevel: (name?: string) => Config<LogLevel.LogLevel> = internal.logLevel
|
|
182
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Constructs a config for a duration value.
|
|
186
|
+
*
|
|
187
|
+
* @since 2.5.0
|
|
188
|
+
* @category constructors
|
|
189
|
+
*/
|
|
190
|
+
export const duration: (name?: string) => Config<Duration.Duration> = internal.duration
|
|
191
|
+
|
|
183
192
|
/**
|
|
184
193
|
* This function returns `true` if the specified value is an `Config` value,
|
|
185
194
|
* `false` otherwise.
|
package/src/Duration.ts
CHANGED
|
@@ -11,7 +11,7 @@ import * as Option from "./Option.js"
|
|
|
11
11
|
import * as order from "./Order.js"
|
|
12
12
|
import type { Pipeable } from "./Pipeable.js"
|
|
13
13
|
import { pipeArguments } from "./Pipeable.js"
|
|
14
|
-
import { hasProperty, isBigInt, isNumber } from "./Predicate.js"
|
|
14
|
+
import { hasProperty, isBigInt, isNumber, isString } from "./Predicate.js"
|
|
15
15
|
|
|
16
16
|
const TypeId: unique symbol = Symbol.for("effect/Duration")
|
|
17
17
|
|
|
@@ -94,7 +94,7 @@ export const decode = (input: DurationInput): Duration => {
|
|
|
94
94
|
if (input.length === 2 && isNumber(input[0]) && isNumber(input[1])) {
|
|
95
95
|
return nanos(BigInt(input[0]) * bigint1e9 + BigInt(input[1]))
|
|
96
96
|
}
|
|
97
|
-
} else {
|
|
97
|
+
} else if (isString(input)) {
|
|
98
98
|
DURATION_REGEX.lastIndex = 0 // Reset the lastIndex before each use
|
|
99
99
|
const match = DURATION_REGEX.exec(input)
|
|
100
100
|
if (match) {
|
|
@@ -131,6 +131,11 @@ export const decode = (input: DurationInput): Duration => {
|
|
|
131
131
|
throw new Error("Invalid duration input")
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* @since 2.5.0
|
|
136
|
+
*/
|
|
137
|
+
export const decodeUnknown: (u: unknown) => Option.Option<Duration> = Option.liftThrowable(decode) as any
|
|
138
|
+
|
|
134
139
|
const zeroValue: DurationValue = { _tag: "Millis", millis: 0 }
|
|
135
140
|
const infinityValue: DurationValue = { _tag: "Infinity" }
|
|
136
141
|
|
package/src/Request.ts
CHANGED
|
@@ -245,6 +245,7 @@ export const succeed: {
|
|
|
245
245
|
export interface Listeners {
|
|
246
246
|
readonly count: number
|
|
247
247
|
readonly observers: Set<(count: number) => void>
|
|
248
|
+
interrupted: boolean
|
|
248
249
|
addObserver(f: (count: number) => void): void
|
|
249
250
|
removeObserver(f: (count: number) => void): void
|
|
250
251
|
increment(): void
|
|
@@ -309,7 +310,7 @@ export interface Entry<out R> extends Entry.Variance<R> {
|
|
|
309
310
|
readonly listeners: Listeners
|
|
310
311
|
readonly ownerId: FiberId
|
|
311
312
|
readonly state: {
|
|
312
|
-
completed: boolean
|
|
313
|
+
completed: boolean
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
|
package/src/internal/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Chunk from "../Chunk.js"
|
|
2
2
|
import type * as Config from "../Config.js"
|
|
3
3
|
import * as ConfigError from "../ConfigError.js"
|
|
4
|
+
import * as Duration from "../Duration.js"
|
|
4
5
|
import * as Either from "../Either.js"
|
|
5
6
|
import type { LazyArg } from "../Function.js"
|
|
6
7
|
import { constTrue, dual, pipe } from "../Function.js"
|
|
@@ -288,6 +289,15 @@ export const logLevel = (name?: string): Config.Config<LogLevel.LogLevel> => {
|
|
|
288
289
|
return name === undefined ? config : nested(config, name)
|
|
289
290
|
}
|
|
290
291
|
|
|
292
|
+
/** @internal */
|
|
293
|
+
export const duration = (name?: string): Config.Config<Duration.Duration> => {
|
|
294
|
+
const config = mapOrFail(string(), (value) => {
|
|
295
|
+
const duration = Duration.decodeUnknown(value)
|
|
296
|
+
return Either.fromOption(duration, () => configError.InvalidData([], `Expected a duration but received ${value}`))
|
|
297
|
+
})
|
|
298
|
+
return name === undefined ? config : nested(config, name)
|
|
299
|
+
}
|
|
300
|
+
|
|
291
301
|
/** @internal */
|
|
292
302
|
export const map = dual<
|
|
293
303
|
<A, B>(f: (a: A) => B) => (self: Config.Config<A>) => Config.Config<B>,
|
|
@@ -241,8 +241,12 @@ const runBlockedRequests = (self: RequestBlock.RequestBlock) =>
|
|
|
241
241
|
map.set(entry.request as Request<any, any>, entry)
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
const flat = arr.flat()
|
|
244
245
|
return core.fiberRefLocally(
|
|
245
|
-
invokeWithInterrupt(dataSource.runAll(arr),
|
|
246
|
+
invokeWithInterrupt(dataSource.runAll(arr), flat, () =>
|
|
247
|
+
flat.forEach((entry) => {
|
|
248
|
+
entry.listeners.interrupted = true
|
|
249
|
+
})),
|
|
246
250
|
currentRequestMap,
|
|
247
251
|
map
|
|
248
252
|
)
|
|
@@ -2024,7 +2028,7 @@ export const forEachConcurrentDiscard = <A, X, E, R>(
|
|
|
2024
2028
|
}
|
|
2025
2029
|
return exits
|
|
2026
2030
|
}
|
|
2027
|
-
const runFiber = <A, E, R>(eff: Effect.Effect<A, E, R
|
|
2031
|
+
const runFiber = <A, E, R>(eff: Effect.Effect<A, E, R>, interruptImmediately = false) => {
|
|
2028
2032
|
const runnable = core.uninterruptible(graft(eff))
|
|
2029
2033
|
const fiber = unsafeForkUnstarted(
|
|
2030
2034
|
runnable,
|
|
@@ -2033,6 +2037,9 @@ export const forEachConcurrentDiscard = <A, X, E, R>(
|
|
|
2033
2037
|
fiberScope.globalScope
|
|
2034
2038
|
)
|
|
2035
2039
|
parent._scheduler.scheduleTask(() => {
|
|
2040
|
+
if (interruptImmediately) {
|
|
2041
|
+
fiber.unsafeInterruptAsFork(parent.id())
|
|
2042
|
+
}
|
|
2036
2043
|
fiber.resume(runnable)
|
|
2037
2044
|
}, 0)
|
|
2038
2045
|
return fiber
|
|
@@ -2138,16 +2145,44 @@ export const forEachConcurrentDiscard = <A, X, E, R>(
|
|
|
2138
2145
|
}
|
|
2139
2146
|
})
|
|
2140
2147
|
)
|
|
2141
|
-
return core.asUnit(
|
|
2142
|
-
core.
|
|
2143
|
-
restore(internalFiber.join(processingFiber)),
|
|
2144
|
-
(
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2148
|
+
return core.asUnit(
|
|
2149
|
+
core.onExit(
|
|
2150
|
+
core.flatten(restore(internalFiber.join(processingFiber))),
|
|
2151
|
+
core.exitMatch({
|
|
2152
|
+
onFailure: () => {
|
|
2153
|
+
onInterruptSignal()
|
|
2154
|
+
const target = residual.length + 1
|
|
2155
|
+
const concurrency = Math.min(typeof n === "number" ? n : residual.length, residual.length)
|
|
2156
|
+
const toPop = Array.from(residual)
|
|
2157
|
+
return core.async<any, any>((cb) => {
|
|
2158
|
+
const exits: Array<Exit.Exit<any, any>> = []
|
|
2159
|
+
let count = 0
|
|
2160
|
+
let index = 0
|
|
2161
|
+
const check = (index: number, hitNext: boolean) => (exit: Exit.Exit<any, any>) => {
|
|
2162
|
+
exits[index] = exit
|
|
2163
|
+
count++
|
|
2164
|
+
if (count === target) {
|
|
2165
|
+
cb(Option.getOrThrow(core.exitCollectAll(exits, { parallel: true })))
|
|
2166
|
+
}
|
|
2167
|
+
if (toPop.length > 0 && hitNext) {
|
|
2168
|
+
next()
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
const next = () => {
|
|
2172
|
+
runFiber(toPop.pop()!, true).addObserver(check(index, true))
|
|
2173
|
+
index++
|
|
2174
|
+
}
|
|
2175
|
+
processingFiber.addObserver(check(index, false))
|
|
2176
|
+
index++
|
|
2177
|
+
for (let i = 0; i < concurrency; i++) {
|
|
2178
|
+
next()
|
|
2179
|
+
}
|
|
2180
|
+
}) as any
|
|
2181
|
+
},
|
|
2182
|
+
onSuccess: () => core.forEachSequential(joinOrder, (f) => f.inheritAll)
|
|
2183
|
+
})
|
|
2184
|
+
)
|
|
2185
|
+
)
|
|
2151
2186
|
})
|
|
2152
2187
|
)
|
|
2153
2188
|
)
|
|
@@ -3421,8 +3456,13 @@ export const ensuring: {
|
|
|
3421
3456
|
/** @internal */
|
|
3422
3457
|
export const invokeWithInterrupt: <A, E, R>(
|
|
3423
3458
|
self: Effect.Effect<A, E, R>,
|
|
3424
|
-
entries: ReadonlyArray<Entry<unknown
|
|
3425
|
-
) =>
|
|
3459
|
+
entries: ReadonlyArray<Entry<unknown>>,
|
|
3460
|
+
onInterrupt?: () => void
|
|
3461
|
+
) => Effect.Effect<void, E, R> = <A, E, R>(
|
|
3462
|
+
self: Effect.Effect<A, E, R>,
|
|
3463
|
+
entries: ReadonlyArray<Entry<unknown>>,
|
|
3464
|
+
onInterrupt?: () => void
|
|
3465
|
+
) =>
|
|
3426
3466
|
core.fiberIdWith((id) =>
|
|
3427
3467
|
core.flatMap(
|
|
3428
3468
|
core.flatMap(
|
|
@@ -3433,6 +3473,7 @@ export const invokeWithInterrupt: <A, E, R>(
|
|
|
3433
3473
|
const checkDone = () => {
|
|
3434
3474
|
if (counts.every((count) => count === 0)) {
|
|
3435
3475
|
cleanup.forEach((f) => f())
|
|
3476
|
+
onInterrupt?.()
|
|
3436
3477
|
cb(core.interruptFiber(processing))
|
|
3437
3478
|
}
|
|
3438
3479
|
}
|
package/src/internal/query.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type * as Request from "../Request.js"
|
|
|
8
8
|
import type * as RequestResolver from "../RequestResolver.js"
|
|
9
9
|
import * as BlockedRequests from "./blockedRequests.js"
|
|
10
10
|
import { unsafeMakeWith } from "./cache.js"
|
|
11
|
-
import { isInterruptedOnly } from "./cause.js"
|
|
12
11
|
import * as core from "./core.js"
|
|
13
12
|
import { ensuring } from "./fiberRuntime.js"
|
|
14
13
|
import { Listeners } from "./request.js"
|
|
@@ -61,77 +60,81 @@ export const fromRequest = <
|
|
|
61
60
|
const proxy = new Proxy(request, {})
|
|
62
61
|
return core.fiberRefGetWith(currentCacheEnabled, (cacheEnabled) => {
|
|
63
62
|
if (cacheEnabled) {
|
|
64
|
-
|
|
63
|
+
const cached: Effect.Effect<any, any> = core.fiberRefGetWith(currentCache, (cache) =>
|
|
65
64
|
core.flatMap(cache.getEither(proxy), (orNew) => {
|
|
66
65
|
switch (orNew._tag) {
|
|
67
66
|
case "Left": {
|
|
67
|
+
if (orNew.left.listeners.interrupted) {
|
|
68
|
+
return core.flatMap(
|
|
69
|
+
cache.invalidateWhen(proxy, (entry) => entry.handle === orNew.left.handle),
|
|
70
|
+
() => cached
|
|
71
|
+
)
|
|
72
|
+
}
|
|
68
73
|
orNew.left.listeners.increment()
|
|
69
|
-
return core.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
return core.uninterruptibleMask((restore) =>
|
|
75
|
+
core.flatMap(
|
|
76
|
+
core.exit(core.blocked(
|
|
77
|
+
BlockedRequests.empty,
|
|
78
|
+
restore(core.deferredAwait(orNew.left.handle))
|
|
79
|
+
)),
|
|
80
|
+
(exit) => {
|
|
73
81
|
orNew.left.listeners.decrement()
|
|
74
|
-
return
|
|
75
|
-
cache.invalidateWhen(
|
|
76
|
-
proxy,
|
|
77
|
-
(entry) => entry.handle === orNew.left.handle
|
|
78
|
-
),
|
|
79
|
-
() => fromRequest(proxy, ds)
|
|
80
|
-
)
|
|
82
|
+
return exit
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
core.deferredAwait(orNew.left.handle),
|
|
84
|
-
core.sync(() => orNew.left.listeners.decrement())
|
|
85
|
-
)
|
|
86
|
-
})
|
|
84
|
+
)
|
|
87
85
|
)
|
|
88
86
|
}
|
|
89
87
|
case "Right": {
|
|
90
88
|
orNew.right.listeners.increment()
|
|
91
|
-
return core.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
return core.uninterruptibleMask((restore) =>
|
|
90
|
+
core.flatMap(
|
|
91
|
+
core.exit(
|
|
92
|
+
core.blocked(
|
|
93
|
+
BlockedRequests.single(
|
|
94
|
+
ds as RequestResolver.RequestResolver<A>,
|
|
95
|
+
BlockedRequests.makeEntry({
|
|
96
|
+
request: proxy,
|
|
97
|
+
result: orNew.right.handle,
|
|
98
|
+
listeners: orNew.right.listeners,
|
|
99
|
+
ownerId: id,
|
|
100
|
+
state: { completed: false }
|
|
101
|
+
})
|
|
102
|
+
),
|
|
103
|
+
restore(core.deferredAwait(orNew.right.handle))
|
|
104
|
+
)
|
|
105
|
+
),
|
|
106
|
+
() => {
|
|
107
|
+
orNew.right.listeners.decrement()
|
|
108
|
+
return core.deferredAwait(orNew.right.handle)
|
|
109
|
+
}
|
|
110
110
|
)
|
|
111
111
|
)
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}))
|
|
115
|
+
return cached
|
|
115
116
|
}
|
|
116
117
|
const listeners = new Listeners()
|
|
117
118
|
listeners.increment()
|
|
118
119
|
return core.flatMap(
|
|
119
120
|
core.deferredMake<Request.Request.Success<A>, Request.Request.Error<A>>(),
|
|
120
121
|
(ref) =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
ensuring(
|
|
123
|
+
core.blocked(
|
|
124
|
+
BlockedRequests.single(
|
|
125
|
+
ds as RequestResolver.RequestResolver<A>,
|
|
126
|
+
BlockedRequests.makeEntry({
|
|
127
|
+
request: proxy,
|
|
128
|
+
result: ref,
|
|
129
|
+
listeners,
|
|
130
|
+
ownerId: id,
|
|
131
|
+
state: { completed: false }
|
|
132
|
+
})
|
|
133
|
+
),
|
|
134
|
+
core.deferredAwait(ref)
|
|
131
135
|
),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
core.sync(() => listeners.decrement())
|
|
136
|
+
core.sync(() =>
|
|
137
|
+
listeners.decrement()
|
|
135
138
|
)
|
|
136
139
|
)
|
|
137
140
|
)
|
package/src/internal/request.ts
CHANGED
package/src/internal/version.ts
CHANGED