effect 2.0.0-next.46 → 2.0.0-next.47
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/Channel/dist/effect-Channel.cjs.dev.js +3 -3
- package/Channel/dist/effect-Channel.cjs.prod.js +3 -3
- package/GroupBy/dist/effect-GroupBy.cjs.dev.js +4 -4
- package/GroupBy/dist/effect-GroupBy.cjs.prod.js +4 -4
- package/KeyedPool/dist/effect-KeyedPool.cjs.dev.js +2 -2
- package/KeyedPool/dist/effect-KeyedPool.cjs.prod.js +2 -2
- package/Pool/dist/effect-Pool.cjs.dev.js +2 -2
- package/Pool/dist/effect-Pool.cjs.prod.js +2 -2
- package/PubSub/dist/effect-PubSub.cjs.dev.js +1 -1
- package/PubSub/dist/effect-PubSub.cjs.prod.js +1 -1
- package/Queue/dist/effect-Queue.cjs.dev.js +1 -1
- package/Queue/dist/effect-Queue.cjs.prod.js +1 -1
- package/STM/dist/effect-STM.cjs.dev.js +6 -6
- package/STM/dist/effect-STM.cjs.prod.js +6 -6
- package/Sink/dist/effect-Sink.cjs.dev.js +2 -2
- package/Sink/dist/effect-Sink.cjs.prod.js +2 -2
- package/Stream/dist/effect-Stream.cjs.dev.js +4 -4
- package/Stream/dist/effect-Stream.cjs.prod.js +4 -4
- package/Streamable/dist/effect-Streamable.cjs.dev.js +4 -4
- package/Streamable/dist/effect-Streamable.cjs.prod.js +4 -4
- package/SubscriptionRef/dist/effect-SubscriptionRef.cjs.dev.js +3 -3
- package/SubscriptionRef/dist/effect-SubscriptionRef.cjs.prod.js +3 -3
- package/TArray/dist/effect-TArray.cjs.dev.js +8 -8
- package/TArray/dist/effect-TArray.cjs.prod.js +8 -8
- package/TDeferred/dist/effect-TDeferred.cjs.dev.js +7 -7
- package/TDeferred/dist/effect-TDeferred.cjs.prod.js +7 -7
- package/TMap/dist/effect-TMap.cjs.dev.js +9 -9
- package/TMap/dist/effect-TMap.cjs.prod.js +9 -9
- package/TPriorityQueue/dist/effect-TPriorityQueue.cjs.dev.js +6 -6
- package/TPriorityQueue/dist/effect-TPriorityQueue.cjs.prod.js +6 -6
- package/TPubSub/dist/effect-TPubSub.cjs.dev.js +8 -8
- package/TPubSub/dist/effect-TPubSub.cjs.prod.js +8 -8
- package/TQueue/dist/effect-TQueue.cjs.dev.js +8 -8
- package/TQueue/dist/effect-TQueue.cjs.prod.js +8 -8
- package/TRandom/dist/effect-TRandom.cjs.dev.js +8 -8
- package/TRandom/dist/effect-TRandom.cjs.prod.js +8 -8
- package/TReentrantLock/dist/effect-TReentrantLock.cjs.dev.js +6 -6
- package/TReentrantLock/dist/effect-TReentrantLock.cjs.prod.js +6 -6
- package/TRef/dist/effect-TRef.cjs.dev.js +6 -6
- package/TRef/dist/effect-TRef.cjs.prod.js +6 -6
- package/TSemaphore/dist/effect-TSemaphore.cjs.dev.js +7 -7
- package/TSemaphore/dist/effect-TSemaphore.cjs.prod.js +7 -7
- package/TSet/dist/effect-TSet.cjs.dev.js +9 -9
- package/TSet/dist/effect-TSet.cjs.prod.js +9 -9
- package/dist/{core-7411d1e1.cjs.prod.js → core-84e608f0.cjs.prod.js} +1 -1
- package/dist/{core-c5747f88.cjs.dev.js → core-c01fd1d8.cjs.dev.js} +1 -1
- package/dist/declarations/src/Queue.d.ts +5 -0
- package/dist/declarations/src/Queue.d.ts.map +1 -1
- package/dist/{groupBy-724f64ef.cjs.prod.js → groupBy-5fb5d639.cjs.prod.js} +2 -2
- package/dist/{groupBy-862cc2da.cjs.dev.js → groupBy-70c6dc0d.cjs.dev.js} +2 -2
- package/dist/{pool-f77d7705.cjs.prod.js → pool-042cc42b.cjs.prod.js} +1 -1
- package/dist/{pool-3211287f.cjs.dev.js → pool-59df8b4d.cjs.dev.js} +1 -1
- package/dist/{queue-315ea45d.cjs.prod.js → queue-425b92f6.cjs.prod.js} +21 -11
- package/dist/{queue-7a223c44.cjs.dev.js → queue-e4c59627.cjs.dev.js} +21 -11
- package/dist/{stm-8aca0022.cjs.dev.js → stm-5264610b.cjs.dev.js} +1 -1
- package/dist/{stm-f250b596.cjs.prod.js → stm-9dd6be88.cjs.prod.js} +1 -1
- package/dist/{stream-34d80d2c.cjs.dev.js → stream-5e2ed3a9.cjs.dev.js} +1 -1
- package/dist/{stream-ea4f4d44.cjs.prod.js → stream-c9c522f2.cjs.prod.js} +1 -1
- package/dist/{tArray-17f078f2.cjs.dev.js → tArray-77a2ae3c.cjs.dev.js} +3 -3
- package/dist/{tArray-d184e22f.cjs.prod.js → tArray-cac66af4.cjs.prod.js} +3 -3
- package/dist/{tMap-e219f30e.cjs.prod.js → tMap-5ac8ec9c.cjs.prod.js} +4 -4
- package/dist/{tMap-1a5aa78b.cjs.dev.js → tMap-73bbf062.cjs.dev.js} +4 -4
- package/dist/{tQueue-0a4fc773.cjs.dev.js → tQueue-2b1cd0c4.cjs.dev.js} +3 -3
- package/dist/{tQueue-47129ad0.cjs.prod.js → tQueue-dded9b2d.cjs.prod.js} +3 -3
- package/dist/{tRef-ab4c5713.cjs.prod.js → tRef-73c3549e.cjs.prod.js} +1 -1
- package/dist/{tRef-b860ef05.cjs.dev.js → tRef-90f0872b.cjs.dev.js} +1 -1
- package/internal/queue.esm.js +24 -14
- package/package.json +1 -1
- package/src/Queue.ts +8 -0
- package/src/internal/queue.ts +26 -11
- /package/dist/{sink-8d3427e7.cjs.dev.js → sink-17e02d40.cjs.dev.js} +0 -0
- /package/dist/{sink-572d8981.cjs.prod.js → sink-b2fcb569.cjs.prod.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Function_dist_effectFunction = require('../Function/dist/effect-Function.cjs.dev.js');
|
|
4
|
-
var core = require('./core-
|
|
4
|
+
var core = require('./core-c01fd1d8.cjs.dev.js');
|
|
5
5
|
var Option_dist_effectOption = require('../Option/dist/effect-Option.cjs.dev.js');
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
package/internal/queue.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { head, prepend, filter, isEmpty as isEmpty$
|
|
1
|
+
import { head, prepend, filter, isEmpty as isEmpty$2, fromIterable as fromIterable$1, appendAll, append, empty as empty$1 } from '../Chunk/dist/effect-Chunk.esm.js';
|
|
2
2
|
import { pipe, dual } from '../Function/dist/effect-Function.esm.js';
|
|
3
3
|
import { flatMap, sync, map, deferredMake, fiberId, withFiberRuntime, unit, succeed, deferredUnsafeDone, deferredInterruptWith, asUnit, deferredUnsafeMake, onInterrupt, suspend, interrupt, deferredAwait, catchAll, uninterruptible, whenEffect, deferredSucceed, zipRight } from './core.esm.js';
|
|
4
4
|
import { forEachParUnboundedDiscard } from './fiberRuntime.esm.js';
|
|
5
|
-
import { bounded as bounded$1, unbounded as unbounded$1, length, poll as poll$1, EmptyMutableQueue, offer as offer$1, offerAll as offerAll$1, pollUpTo, capacity as capacity$1 } from '../MutableQueue/dist/effect-MutableQueue.esm.js';
|
|
5
|
+
import { bounded as bounded$1, unbounded as unbounded$1, length, isEmpty as isEmpty$1, poll as poll$1, EmptyMutableQueue, offer as offer$1, offerAll as offerAll$1, pollUpTo, capacity as capacity$1 } from '../MutableQueue/dist/effect-MutableQueue.esm.js';
|
|
6
6
|
import { make as make$1, get, set } from '../MutableRef/dist/effect-MutableRef.esm.js';
|
|
7
7
|
import { none, some } from '../Option/dist/effect-Option.esm.js';
|
|
8
8
|
import { pipeArguments } from '../Pipeable/dist/effect-Pipeable.esm.js';
|
|
@@ -162,7 +162,7 @@ class QueueImpl {
|
|
|
162
162
|
// Not enough takers, offer to the queue
|
|
163
163
|
const surplus = this.queue.offerAll(remaining);
|
|
164
164
|
unsafeCompleteTakers(this.strategy, this.queue, this.takers);
|
|
165
|
-
return isEmpty$
|
|
165
|
+
return isEmpty$2(surplus) ? succeed(true) : this.strategy.handleSurplus(surplus, this.queue, this.takers, this.shutdownFlag);
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
take() {
|
|
@@ -353,6 +353,16 @@ class BackPressureStrategy {
|
|
|
353
353
|
surplusSize() {
|
|
354
354
|
return length(this.putters);
|
|
355
355
|
}
|
|
356
|
+
onCompleteTakersWithEmptyQueue(takers) {
|
|
357
|
+
while (!isEmpty$1(this.putters) && !isEmpty$1(takers)) {
|
|
358
|
+
const taker = poll$1(takers, void 0);
|
|
359
|
+
const putter = poll$1(this.putters, void 0);
|
|
360
|
+
if (putter[2]) {
|
|
361
|
+
unsafeCompleteDeferred(putter[1], true);
|
|
362
|
+
}
|
|
363
|
+
unsafeCompleteDeferred(taker, putter[0]);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
356
366
|
shutdown() {
|
|
357
367
|
return pipe(fiberId, flatMap(fiberId => pipe(sync(() => unsafePollAll(this.putters)), flatMap(putters => forEachParUnboundedDiscard(putters, ([_, deferred, isLastItem]) => isLastItem ? pipe(deferredInterruptWith(deferred, fiberId), asUnit) : unit, false)))));
|
|
358
368
|
}
|
|
@@ -385,17 +395,12 @@ class BackPressureStrategy {
|
|
|
385
395
|
}
|
|
386
396
|
}
|
|
387
397
|
unsafeOffer(iterable, deferred) {
|
|
388
|
-
const
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
next = iterator.next();
|
|
395
|
-
if (next.done) {
|
|
396
|
-
pipe(this.putters, offer$1([value, deferred, true]));
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
398
|
+
const stuff = Array.from(iterable);
|
|
399
|
+
for (let i = 0; i < stuff.length; i++) {
|
|
400
|
+
const value = stuff[i];
|
|
401
|
+
if (i === stuff.length - 1) {
|
|
402
|
+
pipe(this.putters, offer$1([value, deferred, true]));
|
|
403
|
+
} else {
|
|
399
404
|
pipe(this.putters, offer$1([value, deferred, false]));
|
|
400
405
|
}
|
|
401
406
|
}
|
|
@@ -414,6 +419,7 @@ class DroppingStrategy {
|
|
|
414
419
|
shutdown() {
|
|
415
420
|
return unit;
|
|
416
421
|
}
|
|
422
|
+
onCompleteTakersWithEmptyQueue() {}
|
|
417
423
|
handleSurplus(_iterable, _queue, _takers, _isShutdown) {
|
|
418
424
|
return succeed(false);
|
|
419
425
|
}
|
|
@@ -431,6 +437,7 @@ class SlidingStrategy {
|
|
|
431
437
|
shutdown() {
|
|
432
438
|
return unit;
|
|
433
439
|
}
|
|
440
|
+
onCompleteTakersWithEmptyQueue() {}
|
|
434
441
|
handleSurplus(iterable, queue, takers, _isShutdown) {
|
|
435
442
|
return sync(() => {
|
|
436
443
|
this.unsafeOffer(queue, iterable);
|
|
@@ -500,6 +507,9 @@ const unsafeCompleteTakers = (strategy, queue, takers) => {
|
|
|
500
507
|
keepPolling = false;
|
|
501
508
|
}
|
|
502
509
|
}
|
|
510
|
+
if (keepPolling && queue.length() === 0 && !isEmpty$1(takers)) {
|
|
511
|
+
strategy.onCompleteTakersWithEmptyQueue(takers);
|
|
512
|
+
}
|
|
503
513
|
};
|
|
504
514
|
|
|
505
515
|
export { BackingQueueFromMutableQueue, DequeueTypeId, EnqueueTypeId, QueueStrategyTypeId, awaitShutdown, backPressureStrategy, backingQueueFromMutableQueue, bounded, capacity, dequeueVariance, dropping, droppingStrategy, enqueueVariance, isDequeue, isEmpty, isEnqueue, isFull, isQueue, isShutdown, make, offer, offerAll, poll, shutdown, size, sliding, slidingStrategy, take, takeAll, takeBetween, takeN, takeUpTo, unbounded, unsafeCompleteTakers, unsafeOffer, unsafeRemove };
|
package/package.json
CHANGED
package/src/Queue.ts
CHANGED
|
@@ -216,6 +216,14 @@ export interface Strategy<A> extends Queue.StrategyVariance<A> {
|
|
|
216
216
|
isShutdown: MutableRef.MutableRef<boolean>
|
|
217
217
|
): Effect.Effect<never, never, boolean>
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* It is called when the backing queue is empty but there are some
|
|
221
|
+
* takers that can be completed
|
|
222
|
+
*/
|
|
223
|
+
onCompleteTakersWithEmptyQueue(
|
|
224
|
+
takers: MutableQueue.MutableQueue<Deferred.Deferred<never, A>>
|
|
225
|
+
): void
|
|
226
|
+
|
|
219
227
|
/**
|
|
220
228
|
* Determines the behavior of the `Queue.Strategy` when the `Queue` has empty
|
|
221
229
|
* slots following a `take` operation.
|
package/src/internal/queue.ts
CHANGED
|
@@ -513,6 +513,17 @@ class BackPressureStrategy<A> implements Queue.Strategy<A> {
|
|
|
513
513
|
return MutableQueue.length(this.putters)
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
onCompleteTakersWithEmptyQueue(takers: MutableQueue.MutableQueue<Deferred.Deferred<never, A>>): void {
|
|
517
|
+
while (!MutableQueue.isEmpty(this.putters) && !MutableQueue.isEmpty(takers)) {
|
|
518
|
+
const taker = MutableQueue.poll(takers, void 0)!
|
|
519
|
+
const putter = MutableQueue.poll(this.putters, void 0)!
|
|
520
|
+
if (putter[2]) {
|
|
521
|
+
unsafeCompleteDeferred(putter[1], true)
|
|
522
|
+
}
|
|
523
|
+
unsafeCompleteDeferred(taker, putter[0])
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
516
527
|
shutdown(): Effect.Effect<never, never, void> {
|
|
517
528
|
return pipe(
|
|
518
529
|
core.fiberId,
|
|
@@ -575,17 +586,12 @@ class BackPressureStrategy<A> implements Queue.Strategy<A> {
|
|
|
575
586
|
}
|
|
576
587
|
|
|
577
588
|
unsafeOffer(iterable: Iterable<A>, deferred: Deferred.Deferred<never, boolean>): void {
|
|
578
|
-
const
|
|
579
|
-
let
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
next = iterator.next()
|
|
585
|
-
if (next.done) {
|
|
586
|
-
pipe(this.putters, MutableQueue.offer([value, deferred, true as boolean] as const))
|
|
587
|
-
break
|
|
588
|
-
}
|
|
589
|
+
const stuff = Array.from(iterable)
|
|
590
|
+
for (let i = 0; i < stuff.length; i++) {
|
|
591
|
+
const value = stuff[i]
|
|
592
|
+
if (i === stuff.length - 1) {
|
|
593
|
+
pipe(this.putters, MutableQueue.offer([value, deferred, true as boolean] as const))
|
|
594
|
+
} else {
|
|
589
595
|
pipe(this.putters, MutableQueue.offer([value, deferred, false as boolean] as const))
|
|
590
596
|
}
|
|
591
597
|
}
|
|
@@ -611,6 +617,9 @@ class DroppingStrategy<A> implements Queue.Strategy<A> {
|
|
|
611
617
|
return core.unit
|
|
612
618
|
}
|
|
613
619
|
|
|
620
|
+
onCompleteTakersWithEmptyQueue(): void {
|
|
621
|
+
}
|
|
622
|
+
|
|
614
623
|
handleSurplus(
|
|
615
624
|
_iterable: Iterable<A>,
|
|
616
625
|
_queue: Queue.BackingQueue<A>,
|
|
@@ -640,6 +649,9 @@ class SlidingStrategy<A> implements Queue.Strategy<A> {
|
|
|
640
649
|
return core.unit
|
|
641
650
|
}
|
|
642
651
|
|
|
652
|
+
onCompleteTakersWithEmptyQueue(): void {
|
|
653
|
+
}
|
|
654
|
+
|
|
643
655
|
handleSurplus(
|
|
644
656
|
iterable: Iterable<A>,
|
|
645
657
|
queue: Queue.BackingQueue<A>,
|
|
@@ -726,4 +738,7 @@ export const unsafeCompleteTakers = <A>(
|
|
|
726
738
|
keepPolling = false
|
|
727
739
|
}
|
|
728
740
|
}
|
|
741
|
+
if (keepPolling && queue.length() === 0 && !MutableQueue.isEmpty(takers)) {
|
|
742
|
+
strategy.onCompleteTakersWithEmptyQueue(takers)
|
|
743
|
+
}
|
|
729
744
|
}
|
|
File without changes
|
|
File without changes
|