@effect/stream
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -285,6 +285,6 @@ "use strict"; | ||
const errorSignal = yield* $(Deferred.make()); | ||
const permits = yield* $(Effect.makeSemaphore(n)); | ||
const withPermits = n === Number.POSITIVE_INFINITY ? _ => _Function.identity : (yield* $(Effect.makeSemaphore(n))).withPermits; | ||
const pull = yield* $(toPull(self)); | ||
yield* $(Effect.forkScoped(Effect.interruptible(Effect.forever(Effect.matchCauseEffect(cause => Queue.offer(Effect.failCause(cause))(queue), either => Either.match(outDone => { | ||
const lock = permits(n); | ||
const lock = withPermits(n); | ||
return Effect.zipRight(Effect.asUnit(Queue.offer(Effect.succeed(Either.left(outDone)))(queue)))(Effect.interruptible(lock(Effect.unit()))); | ||
@@ -295,3 +295,3 @@ }, outElem => Effect.gen(function* ($) { | ||
yield* $(Effect.asUnit(Queue.offer(Effect.map(Either.right)(Deferred.await(deferred)))(queue))); | ||
yield* $(Effect.forkScoped(permits(1)(Effect.zipRight(Effect.intoDeferred(deferred)(Effect.tapErrorCause(cause => Deferred.failCause(cause)(errorSignal))(Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.done)(Effect.raceFirst(Effect.exit(restore(f(outElem))))(Effect.exit(restore(Deferred.await(errorSignal)))))))))(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(Effect.intoDeferred(deferred)(Effect.tapErrorCause(cause => Deferred.failCause(cause)(errorSignal))(Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.done)(Effect.raceFirst(Effect.exit(restore(f(outElem))))(Effect.exit(restore(Deferred.await(errorSignal)))))))))(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Deferred.await(latch)); | ||
@@ -329,9 +329,9 @@ }))(either))(pull))))); | ||
const errorSignal = yield* $(Deferred.make()); | ||
const permits = yield* $(Effect.makeSemaphore(n)); | ||
const withPermits = n === Number.POSITIVE_INFINITY ? _ => _Function.identity : (yield* $(Effect.makeSemaphore(n))).withPermits; | ||
const pull = yield* $(toPull(channels)); | ||
const evaluatePull = pull => Effect.catchAllCause(cause => Cause.isInterrupted(cause) ? Effect.failCause(cause) : Effect.asUnit(Effect.zipRight(Deferred.succeed(void 0)(errorSignal))(Queue.offer(Effect.failCause(cause))(queue))))(Effect.flatMap(Option.match(() => Effect.unit(), outDone => Ref.update(Option.match(() => Option.some(outDone), lastDone => Option.some(f(lastDone, outDone))))(lastDone)))(Effect.repeatUntil(Option.isSome)(Effect.flatMap(Either.match(done => Effect.succeed(Option.some(done)), outElem => Effect.as(Option.none)(Queue.offer(Effect.succeed(Either.right(outElem)))(queue))))(pull)))); | ||
yield* $(Effect.forkScoped(Effect.repeatWhileEquals(true)(Effect.matchCauseEffect(cause => Effect.zipRight(Effect.succeed(false))(Queue.offer(Effect.failCause(cause))(queue)), Either.match(outDone => Effect.raceWith(permits(n)(Effect.unit()), (_, permitAcquisition) => Effect.as(false)(Fiber.interrupt(permitAcquisition)), (_, failureAwait) => Effect.zipRight(Effect.as(false)(Effect.flatMap(Option.match(() => Queue.offer(Effect.succeed(Either.left(outDone)))(queue), lastDone => Queue.offer(Effect.succeed(Either.left(f(lastDone, outDone))))(queue)))(Ref.get(lastDone))))(Fiber.interrupt(failureAwait)))(Deferred.await(errorSignal)), channel => _mergeStrategy.match(() => Effect.gen(function* ($) { | ||
yield* $(Effect.forkScoped(Effect.repeatWhileEquals(true)(Effect.matchCauseEffect(cause => Effect.zipRight(Effect.succeed(false))(Queue.offer(Effect.failCause(cause))(queue)), Either.match(outDone => Effect.raceWith(withPermits(n)(Effect.unit()), (_, permitAcquisition) => Effect.as(false)(Fiber.interrupt(permitAcquisition)), (_, failureAwait) => Effect.zipRight(Effect.as(false)(Effect.flatMap(Option.match(() => Queue.offer(Effect.succeed(Either.left(outDone)))(queue), lastDone => Queue.offer(Effect.succeed(Either.left(f(lastDone, outDone))))(queue)))(Ref.get(lastDone))))(Fiber.interrupt(failureAwait)))(Deferred.await(errorSignal)), channel => _mergeStrategy.match(() => Effect.gen(function* ($) { | ||
const latch = yield* $(Deferred.make()); | ||
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull)))(toPull(core.pipeTo(channel)(queueReader)))); | ||
yield* $(Effect.forkScoped(permits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Deferred.await(latch)); | ||
@@ -347,3 +347,3 @@ const errored = yield* $(Deferred.isDone(errorSignal)); | ||
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(canceler))(Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull))))(toPull(core.pipeTo(channel)(queueReader)))); | ||
yield* $(Effect.forkScoped(permits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(void 0)(latch))))); | ||
yield* $(Deferred.await(latch)); | ||
@@ -350,0 +350,0 @@ const errored = yield* $(Deferred.isDone(errorSignal)); |
@@ -41,3 +41,3 @@ "use strict"; | ||
get changes() { | ||
return stream.unwrapScoped(this.semaphore(1)(Effect.flatMap(a => Effect.map(s => stream.concat(s)(stream.make(a)))(stream.fromHubScoped(this.hub)))(Ref.get(this.ref)))); | ||
return stream.unwrapScoped(this.semaphore.withPermits(1)(Effect.flatMap(a => Effect.map(s => stream.concat(s)(stream.make(a)))(stream.fromHubScoped(this.hub)))(Ref.get(this.ref)))); | ||
} | ||
@@ -52,3 +52,3 @@ /** @macro traced */ | ||
const trace = (0, _Debug.getCallTrace)(); | ||
return this.semaphore(1)(Effect.flatMap(([b, a]) => Effect.zipLeft(Hub.publish(a)(this.hub))(Effect.as(b)(Ref.set(a)(this.ref))))(Effect.flatMap(f)(Ref.get(this.ref)))).traced(trace); | ||
return this.semaphore.withPermits(1)(Effect.flatMap(([b, a]) => Effect.zipLeft(Hub.publish(a)(this.hub))(Effect.as(b)(Ref.set(a)(this.ref))))(Effect.flatMap(f)(Ref.get(this.ref)))).traced(trace); | ||
} | ||
@@ -84,5 +84,5 @@ } | ||
const trace = (0, _Debug.getCallTrace)(); | ||
return self => self.semaphore(1)(Effect.zipLeft(Hub.publish(value)(self.hub))(Ref.set(value)(self.ref))).traced(trace); | ||
return self => self.semaphore.withPermits(1)(Effect.zipLeft(Hub.publish(value)(self.hub))(Ref.set(value)(self.ref))).traced(trace); | ||
}; | ||
exports.set = set; | ||
//# sourceMappingURL=subscriptionRef.js.map |
{ | ||
"name": "@effect/stream", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"dependencies": { | ||
"@effect/io": "~0.0.52", | ||
"@effect/io": "~0.0.57", | ||
"@fp-ts/core": "~0.0.11", | ||
@@ -13,0 +13,0 @@ "@fp-ts/data": "~0.0.36" |
@@ -53,3 +53,3 @@ import { getCallTrace } from "@effect/io/Debug" | ||
), | ||
this.semaphore(1), | ||
this.semaphore.withPermits(1), | ||
stream.unwrapScoped | ||
@@ -77,3 +77,3 @@ ) | ||
), | ||
this.semaphore(1) | ||
this.semaphore.withPermits(1) | ||
).traced(trace) | ||
@@ -122,4 +122,4 @@ } | ||
Effect.zipLeft(pipe(self.hub, Hub.publish(value))), | ||
self.semaphore(1) | ||
self.semaphore.withPermits(1) | ||
).traced(trace) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3012201
53996
Updated@effect/io@~0.0.57