poolifier 5.1.7 → 5.3.0
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/README.md +1 -0
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +100 -61
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -88,11 +88,11 @@ declare const Measurements: Readonly<{
|
|
|
88
88
|
interface IWorkerChoiceStrategy {
|
|
89
89
|
/**
|
|
90
90
|
* Chooses a worker node in the pool and returns its key.
|
|
91
|
-
* If no worker nodes are
|
|
92
|
-
* If
|
|
91
|
+
* If no worker nodes are eligible, `undefined` is returned and the caller retries.
|
|
92
|
+
* @param workerNodeKeysSet - The worker node keys affinity set. If undefined, all workers are eligible.
|
|
93
93
|
* @returns The worker node key or `undefined`.
|
|
94
94
|
*/
|
|
95
|
-
readonly choose: () => number | undefined;
|
|
95
|
+
readonly choose: (workerNodeKeysSet?: ReadonlySet<number>) => number | undefined;
|
|
96
96
|
/**
|
|
97
97
|
* The worker choice strategy name.
|
|
98
98
|
*/
|
|
@@ -276,8 +276,8 @@ interface WorkerOptions {
|
|
|
276
276
|
|
|
277
277
|
/**
|
|
278
278
|
* Message object that is passed between main worker and worker.
|
|
279
|
-
* @
|
|
280
|
-
* @
|
|
279
|
+
* @template Data - Type of data sent to the worker or execution response. This can only be structured-cloneable data.
|
|
280
|
+
* @template ErrorData - Type of data sent to the worker triggering an error. This can only be structured-cloneable data.
|
|
281
281
|
* @internal
|
|
282
282
|
*/
|
|
283
283
|
interface MessageValue<Data = unknown, ErrorData = unknown> extends Task<Data> {
|
|
@@ -344,7 +344,7 @@ interface MessageValue<Data = unknown, ErrorData = unknown> extends Task<Data> {
|
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* An object holding the task execution response promise resolve/reject callbacks.
|
|
347
|
-
* @
|
|
347
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
348
348
|
* @internal
|
|
349
349
|
*/
|
|
350
350
|
interface PromiseResponseWrapper<Response = unknown> {
|
|
@@ -371,7 +371,7 @@ interface PromiseResponseWrapper<Response = unknown> {
|
|
|
371
371
|
}
|
|
372
372
|
/**
|
|
373
373
|
* Message object that is passed as a task between main worker and worker.
|
|
374
|
-
* @
|
|
374
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
375
375
|
* @internal
|
|
376
376
|
*/
|
|
377
377
|
interface Task<Data = unknown> {
|
|
@@ -425,6 +425,13 @@ interface TaskFunctionProperties {
|
|
|
425
425
|
* Task function worker choice strategy.
|
|
426
426
|
*/
|
|
427
427
|
readonly strategy?: WorkerChoiceStrategy;
|
|
428
|
+
/**
|
|
429
|
+
* Task function worker node keys affinity.
|
|
430
|
+
* Restricts task execution to specified worker nodes by their indices.
|
|
431
|
+
* Must contain valid indices within [0, pool max size - 1].
|
|
432
|
+
* If undefined, task can execute on any worker node.
|
|
433
|
+
*/
|
|
434
|
+
readonly workerNodeKeys?: number[];
|
|
428
435
|
}
|
|
429
436
|
/**
|
|
430
437
|
* Task performance.
|
|
@@ -450,7 +457,7 @@ interface TaskPerformance {
|
|
|
450
457
|
}
|
|
451
458
|
/**
|
|
452
459
|
* Worker error.
|
|
453
|
-
* @
|
|
460
|
+
* @template Data - Type of data sent to the worker triggering an error. This can only be structured-cloneable data.
|
|
454
461
|
*/
|
|
455
462
|
interface WorkerError<Data = unknown> {
|
|
456
463
|
/**
|
|
@@ -494,7 +501,7 @@ interface WorkerStatistics {
|
|
|
494
501
|
}
|
|
495
502
|
/**
|
|
496
503
|
* Remove readonly modifier from all properties of T.
|
|
497
|
-
* @
|
|
504
|
+
* @template T - Type to remove readonly modifier.
|
|
498
505
|
* @internal
|
|
499
506
|
*/
|
|
500
507
|
type Writable<T> = {
|
|
@@ -506,21 +513,21 @@ type Writable<T> = {
|
|
|
506
513
|
* This function must return a promise.
|
|
507
514
|
* @param data - Data sent to the worker.
|
|
508
515
|
* @returns Execution response promise.
|
|
509
|
-
* @
|
|
510
|
-
* @
|
|
516
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
517
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
511
518
|
*/
|
|
512
519
|
type TaskAsyncFunction<Data = unknown, Response = unknown> = (data?: Data) => Promise<Response>;
|
|
513
520
|
/**
|
|
514
521
|
* Task function that can be executed.
|
|
515
522
|
* This function can be synchronous or asynchronous.
|
|
516
|
-
* @
|
|
517
|
-
* @
|
|
523
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
524
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
518
525
|
*/
|
|
519
526
|
type TaskFunction<Data = unknown, Response = unknown> = TaskAsyncFunction<Data, Response> | TaskSyncFunction<Data, Response>;
|
|
520
527
|
/**
|
|
521
528
|
* Task function object.
|
|
522
|
-
* @
|
|
523
|
-
* @
|
|
529
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
530
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
524
531
|
*/
|
|
525
532
|
interface TaskFunctionObject<Data = unknown, Response = unknown> {
|
|
526
533
|
/**
|
|
@@ -535,6 +542,13 @@ interface TaskFunctionObject<Data = unknown, Response = unknown> {
|
|
|
535
542
|
* Task function.
|
|
536
543
|
*/
|
|
537
544
|
taskFunction: TaskFunction<Data, Response>;
|
|
545
|
+
/**
|
|
546
|
+
* Task function worker node keys affinity.
|
|
547
|
+
* Restricts task execution to specified worker nodes by their indices.
|
|
548
|
+
* Must contain valid indices within [0, pool max size - 1].
|
|
549
|
+
* If undefined, task can execute on any worker node.
|
|
550
|
+
*/
|
|
551
|
+
workerNodeKeys?: number[];
|
|
538
552
|
}
|
|
539
553
|
/**
|
|
540
554
|
* Task function operation result.
|
|
@@ -547,22 +561,22 @@ interface TaskFunctionOperationResult {
|
|
|
547
561
|
* Tasks functions that can be executed.
|
|
548
562
|
* The key is the name of the task function or task function object.
|
|
549
563
|
* The value is the task function or task function object.
|
|
550
|
-
* @
|
|
551
|
-
* @
|
|
564
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
565
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
552
566
|
*/
|
|
553
567
|
type TaskFunctions<Data = unknown, Response = unknown> = Record<string, TaskFunction<Data, Response> | TaskFunctionObject<Data, Response>>;
|
|
554
568
|
/**
|
|
555
569
|
* Task synchronous function that can be executed.
|
|
556
570
|
* @param data - Data sent to the worker.
|
|
557
571
|
* @returns Execution response.
|
|
558
|
-
* @
|
|
559
|
-
* @
|
|
572
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
573
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
560
574
|
*/
|
|
561
575
|
type TaskSyncFunction<Data = unknown, Response = unknown> = (data?: Data) => Response;
|
|
562
576
|
|
|
563
577
|
/**
|
|
564
578
|
* Priority queue.
|
|
565
|
-
* @
|
|
579
|
+
* @template T - Type of priority queue data.
|
|
566
580
|
* @internal
|
|
567
581
|
*/
|
|
568
582
|
declare class PriorityQueue<T> {
|
|
@@ -585,8 +599,10 @@ declare class PriorityQueue<T> {
|
|
|
585
599
|
* @param enablePriority - Whether to enable priority.
|
|
586
600
|
*/
|
|
587
601
|
set enablePriority(enablePriority: boolean);
|
|
602
|
+
private readonly agingFactor;
|
|
588
603
|
private readonly bucketSize;
|
|
589
604
|
private head;
|
|
605
|
+
private readonly loadExponent;
|
|
590
606
|
private priorityEnabled;
|
|
591
607
|
private tail;
|
|
592
608
|
/**
|
|
@@ -595,9 +611,13 @@ declare class PriorityQueue<T> {
|
|
|
595
611
|
* @defaultValue defaultBucketSize
|
|
596
612
|
* @param enablePriority - Whether to enable priority.
|
|
597
613
|
* @defaultValue false
|
|
614
|
+
* @param agingFactor - Aging factor for priority boosting (priority points per millisecond).
|
|
615
|
+
* @defaultValue defaultAgingFactor
|
|
616
|
+
* @param loadExponent - Load exponent for aging adjustment based on queue fill ratio.
|
|
617
|
+
* @defaultValue defaultLoadExponent
|
|
598
618
|
* @returns PriorityQueue.
|
|
599
619
|
*/
|
|
600
|
-
constructor(bucketSize?: number, enablePriority?: boolean);
|
|
620
|
+
constructor(bucketSize?: number, enablePriority?: boolean, agingFactor?: number, loadExponent?: number);
|
|
601
621
|
/**
|
|
602
622
|
* Clears the priority queue.
|
|
603
623
|
*/
|
|
@@ -633,27 +653,27 @@ declare class PriorityQueue<T> {
|
|
|
633
653
|
|
|
634
654
|
/**
|
|
635
655
|
* Callback invoked if the worker raised an error.
|
|
636
|
-
* @
|
|
656
|
+
* @template Worker - Type of worker.
|
|
637
657
|
*/
|
|
638
658
|
type ErrorHandler<Worker extends IWorker> = (this: Worker, error: Error) => void;
|
|
639
659
|
/**
|
|
640
660
|
* Worker event handler.
|
|
641
|
-
* @
|
|
661
|
+
* @template Worker - Type of worker.
|
|
642
662
|
*/
|
|
643
663
|
type EventHandler<Worker extends IWorker> = ErrorHandler<Worker> | ExitHandler<Worker> | MessageHandler<Worker> | OnlineHandler<Worker>;
|
|
644
664
|
/**
|
|
645
665
|
* Callback invoked when the worker exits successfully.
|
|
646
|
-
* @
|
|
666
|
+
* @template Worker - Type of worker.
|
|
647
667
|
*/
|
|
648
668
|
type ExitHandler<Worker extends IWorker> = (this: Worker, exitCode: number) => void;
|
|
649
669
|
/**
|
|
650
670
|
* Callback invoked if the worker has received a message.
|
|
651
|
-
* @
|
|
671
|
+
* @template Worker - Type of worker.
|
|
652
672
|
*/
|
|
653
673
|
type MessageHandler<Worker extends IWorker> = (this: Worker, message: unknown) => void;
|
|
654
674
|
/**
|
|
655
675
|
* Callback invoked when the worker has started successfully.
|
|
656
|
-
* @
|
|
676
|
+
* @template Worker - Type of worker.
|
|
657
677
|
*/
|
|
658
678
|
type OnlineHandler<Worker extends IWorker> = (this: Worker) => void;
|
|
659
679
|
/**
|
|
@@ -783,8 +803,8 @@ interface IWorker extends EventEmitter {
|
|
|
783
803
|
}
|
|
784
804
|
/**
|
|
785
805
|
* Worker node interface.
|
|
786
|
-
* @
|
|
787
|
-
* @
|
|
806
|
+
* @template Worker - Type of worker.
|
|
807
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
788
808
|
* @internal
|
|
789
809
|
*/
|
|
790
810
|
interface IWorkerNode<Worker extends IWorker, Data = unknown> extends EventEmitter {
|
|
@@ -963,8 +983,10 @@ interface WorkerNodeEventDetail {
|
|
|
963
983
|
*/
|
|
964
984
|
interface WorkerNodeOptions {
|
|
965
985
|
env?: Record<string, unknown>;
|
|
986
|
+
tasksQueueAgingFactor: number | undefined;
|
|
966
987
|
tasksQueueBackPressureSize: number | undefined;
|
|
967
988
|
tasksQueueBucketSize: number | undefined;
|
|
989
|
+
tasksQueueLoadExponent: number | undefined;
|
|
968
990
|
tasksQueuePriority: boolean | undefined;
|
|
969
991
|
workerOptions?: WorkerOptions$1;
|
|
970
992
|
}
|
|
@@ -1024,9 +1046,9 @@ declare const PoolEvents: Readonly<{
|
|
|
1024
1046
|
}>;
|
|
1025
1047
|
/**
|
|
1026
1048
|
* Contract definition for a poolifier pool.
|
|
1027
|
-
* @
|
|
1028
|
-
* @
|
|
1029
|
-
* @
|
|
1049
|
+
* @template Worker - Type of worker which manages this pool.
|
|
1050
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1051
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1030
1052
|
*/
|
|
1031
1053
|
interface IPool<Worker extends IWorker, Data = unknown, Response = unknown> {
|
|
1032
1054
|
/**
|
|
@@ -1211,7 +1233,7 @@ interface PoolInfo {
|
|
|
1211
1233
|
}
|
|
1212
1234
|
/**
|
|
1213
1235
|
* Options for a poolifier pool.
|
|
1214
|
-
* @
|
|
1236
|
+
* @template Worker - Type of worker.
|
|
1215
1237
|
*/
|
|
1216
1238
|
interface PoolOptions<Worker extends IWorker> {
|
|
1217
1239
|
/**
|
|
@@ -1286,11 +1308,21 @@ interface PoolOptions<Worker extends IWorker> {
|
|
|
1286
1308
|
* Worker node tasks queue options.
|
|
1287
1309
|
*/
|
|
1288
1310
|
interface TasksQueueOptions {
|
|
1311
|
+
/**
|
|
1312
|
+
* Controls the priority queue anti-starvation aging rate.
|
|
1313
|
+
* @defaultValue 0.001
|
|
1314
|
+
*/
|
|
1315
|
+
readonly agingFactor?: number;
|
|
1289
1316
|
/**
|
|
1290
1317
|
* Maximum number of tasks that can be executed concurrently on a worker node.
|
|
1291
1318
|
* @defaultValue 1
|
|
1292
1319
|
*/
|
|
1293
1320
|
readonly concurrency?: number;
|
|
1321
|
+
/**
|
|
1322
|
+
* Controls load-based aging adjustment exponent.
|
|
1323
|
+
* @defaultValue 0.667
|
|
1324
|
+
*/
|
|
1325
|
+
readonly loadExponent?: number;
|
|
1294
1326
|
/**
|
|
1295
1327
|
* Maximum tasks queue size per worker node flagging it as back pressured.
|
|
1296
1328
|
* @defaultValue (pool maximum size)^2
|
|
@@ -1320,9 +1352,9 @@ interface TasksQueueOptions {
|
|
|
1320
1352
|
|
|
1321
1353
|
/**
|
|
1322
1354
|
* The worker choice strategies context.
|
|
1323
|
-
* @
|
|
1324
|
-
* @
|
|
1325
|
-
* @
|
|
1355
|
+
* @template Worker - Type of worker.
|
|
1356
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1357
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1326
1358
|
* @internal
|
|
1327
1359
|
*/
|
|
1328
1360
|
declare class WorkerChoiceStrategiesContext<Worker extends IWorker, Data = unknown, Response = unknown> {
|
|
@@ -1356,13 +1388,13 @@ declare class WorkerChoiceStrategiesContext<Worker extends IWorker, Data = unkno
|
|
|
1356
1388
|
*/
|
|
1357
1389
|
constructor(pool: IPool<Worker, Data, Response>, workerChoiceStrategies?: WorkerChoiceStrategy[], opts?: WorkerChoiceStrategyOptions);
|
|
1358
1390
|
/**
|
|
1359
|
-
* Executes the given worker choice strategy
|
|
1360
|
-
* @param workerChoiceStrategy - The worker choice strategy
|
|
1361
|
-
* @
|
|
1391
|
+
* Executes the given worker choice strategy.
|
|
1392
|
+
* @param workerChoiceStrategy - The worker choice strategy.
|
|
1393
|
+
* @param workerNodeKeysSet - The worker node keys affinity set. If undefined, all workers are eligible.
|
|
1362
1394
|
* @returns The key of the worker node.
|
|
1363
1395
|
* @throws {Error} If after computed retries the worker node key is null or undefined.
|
|
1364
1396
|
*/
|
|
1365
|
-
execute(workerChoiceStrategy?: WorkerChoiceStrategy): number;
|
|
1397
|
+
execute(workerChoiceStrategy?: WorkerChoiceStrategy, workerNodeKeysSet?: ReadonlySet<number>): number;
|
|
1366
1398
|
/**
|
|
1367
1399
|
* Gets the active worker choice strategies in the context policy.
|
|
1368
1400
|
* @returns The strategies policy.
|
|
@@ -1416,8 +1448,9 @@ declare class WorkerChoiceStrategiesContext<Worker extends IWorker, Data = unkno
|
|
|
1416
1448
|
*/
|
|
1417
1449
|
private addWorkerChoiceStrategy;
|
|
1418
1450
|
/**
|
|
1419
|
-
* Executes the given worker choice strategy.
|
|
1420
|
-
* @param workerChoiceStrategy - The worker choice strategy.
|
|
1451
|
+
* Executes the given worker choice strategy in the context algorithm.
|
|
1452
|
+
* @param workerChoiceStrategy - The worker choice strategy algorithm to execute.
|
|
1453
|
+
* @param workerNodeKeysSet - The worker node keys affinity set. If undefined, all workers are eligible.
|
|
1421
1454
|
* @returns The key of the worker node.
|
|
1422
1455
|
* @throws {Error} If after computed retries the worker node key is null or undefined.
|
|
1423
1456
|
*/
|
|
@@ -1432,9 +1465,9 @@ declare class WorkerChoiceStrategiesContext<Worker extends IWorker, Data = unkno
|
|
|
1432
1465
|
|
|
1433
1466
|
/**
|
|
1434
1467
|
* Base class that implements some shared logic for all poolifier pools.
|
|
1435
|
-
* @
|
|
1436
|
-
* @
|
|
1437
|
-
* @
|
|
1468
|
+
* @template Worker - Type of worker which manages this pool.
|
|
1469
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1470
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1438
1471
|
*/
|
|
1439
1472
|
declare abstract class AbstractPool<Worker extends IWorker, Data = unknown, Response = unknown> implements IPool<Worker, Data, Response> {
|
|
1440
1473
|
protected readonly minimumNumberOfWorkers: number;
|
|
@@ -1726,6 +1759,12 @@ declare abstract class AbstractPool<Worker extends IWorker, Data = unknown, Resp
|
|
|
1726
1759
|
* @returns The task function worker choice strategy if the task function worker choice strategy is defined, `undefined` otherwise.
|
|
1727
1760
|
*/
|
|
1728
1761
|
private readonly getTaskFunctionWorkerChoiceStrategy;
|
|
1762
|
+
/**
|
|
1763
|
+
* Gets task function worker node keys affinity set, if any.
|
|
1764
|
+
* @param name - The task function name.
|
|
1765
|
+
* @returns The task function worker node keys affinity set, or `undefined` if not defined.
|
|
1766
|
+
*/
|
|
1767
|
+
private readonly getTaskFunctionWorkerNodeKeysSet;
|
|
1729
1768
|
private getTasksQueuePriority;
|
|
1730
1769
|
/**
|
|
1731
1770
|
* Gets the worker choice strategies registered in this pool.
|
|
@@ -1817,8 +1856,8 @@ declare abstract class AbstractPool<Worker extends IWorker, Data = unknown, Resp
|
|
|
1817
1856
|
type ClusterPoolOptions = PoolOptions<Worker>;
|
|
1818
1857
|
/**
|
|
1819
1858
|
* A cluster pool with a fixed number of workers.
|
|
1820
|
-
* @
|
|
1821
|
-
* @
|
|
1859
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1860
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1822
1861
|
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
|
|
1823
1862
|
* @since 2.0.0
|
|
1824
1863
|
*/
|
|
@@ -1866,8 +1905,8 @@ declare class FixedClusterPool<Data = unknown, Response = unknown> extends Abstr
|
|
|
1866
1905
|
*
|
|
1867
1906
|
* This cluster pool creates new workers when the others are busy, up to the maximum number of workers.
|
|
1868
1907
|
* When the maximum number of workers is reached and workers are busy, an event is emitted. If you want to listen to this event, use the pool's `emitter`.
|
|
1869
|
-
* @
|
|
1870
|
-
* @
|
|
1908
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1909
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1871
1910
|
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
|
|
1872
1911
|
* @since 2.0.0
|
|
1873
1912
|
*/
|
|
@@ -1918,8 +1957,8 @@ declare class DynamicClusterPool<Data = unknown, Response = unknown> extends Fix
|
|
|
1918
1957
|
type ThreadPoolOptions = PoolOptions<Worker$1>;
|
|
1919
1958
|
/**
|
|
1920
1959
|
* A thread pool with a fixed number of threads.
|
|
1921
|
-
* @
|
|
1922
|
-
* @
|
|
1960
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
1961
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1923
1962
|
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
|
|
1924
1963
|
* @since 0.0.1
|
|
1925
1964
|
*/
|
|
@@ -1965,8 +2004,8 @@ declare class FixedThreadPool<Data = unknown, Response = unknown> extends Abstra
|
|
|
1965
2004
|
*
|
|
1966
2005
|
* This thread pool creates new threads when the others are busy, up to the maximum number of threads.
|
|
1967
2006
|
* When the maximum number of threads is reached and workers are busy, an event is emitted. If you want to listen to this event, use the pool's `emitter`.
|
|
1968
|
-
* @
|
|
1969
|
-
* @
|
|
2007
|
+
* @template Data - Type of data sent to the worker. This can only be structured-cloneable data.
|
|
2008
|
+
* @template Response - Type of execution response. This can only be structured-cloneable data.
|
|
1970
2009
|
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
|
|
1971
2010
|
* @since 0.0.1
|
|
1972
2011
|
*/
|
|
@@ -2013,7 +2052,7 @@ declare class DynamicThreadPool<Data = unknown, Response = unknown> extends Fixe
|
|
|
2013
2052
|
|
|
2014
2053
|
/**
|
|
2015
2054
|
* Fixed queue node.
|
|
2016
|
-
* @
|
|
2055
|
+
* @template T - Type of fixed queue node data.
|
|
2017
2056
|
* @internal
|
|
2018
2057
|
*/
|
|
2019
2058
|
interface FixedQueueNode<T> {
|
|
@@ -2023,7 +2062,7 @@ interface FixedQueueNode<T> {
|
|
|
2023
2062
|
}
|
|
2024
2063
|
/**
|
|
2025
2064
|
* Fixed queue.
|
|
2026
|
-
* @
|
|
2065
|
+
* @template T - Type of fixed queue data.
|
|
2027
2066
|
* @internal
|
|
2028
2067
|
*/
|
|
2029
2068
|
interface IFixedQueue<T> {
|
|
@@ -2089,9 +2128,9 @@ declare const availableParallelism: () => number;
|
|
|
2089
2128
|
|
|
2090
2129
|
/**
|
|
2091
2130
|
* Base class that implements some shared logic for all poolifier workers.
|
|
2092
|
-
* @
|
|
2093
|
-
* @
|
|
2094
|
-
* @
|
|
2131
|
+
* @template MainWorker - Type of main worker.
|
|
2132
|
+
* @template Data - Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
|
|
2133
|
+
* @template Response - Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
|
|
2095
2134
|
*/
|
|
2096
2135
|
declare abstract class AbstractWorker<MainWorker extends MessagePort | Worker, Data = unknown, Response = unknown> {
|
|
2097
2136
|
protected readonly isMain: boolean | undefined;
|
|
@@ -2264,8 +2303,8 @@ declare abstract class AbstractWorker<MainWorker extends MessagePort | Worker, D
|
|
|
2264
2303
|
*
|
|
2265
2304
|
* If you use a `DynamicClusterPool` the extra workers that were created will be terminated,
|
|
2266
2305
|
* but the minimum number of workers will be guaranteed.
|
|
2267
|
-
* @
|
|
2268
|
-
* @
|
|
2306
|
+
* @template Data - Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
|
|
2307
|
+
* @template Response - Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
|
|
2269
2308
|
* @author [Christopher Quadflieg](https://github.com/Shinigami92)
|
|
2270
2309
|
* @since 2.0.0
|
|
2271
2310
|
*/
|
|
@@ -2300,8 +2339,8 @@ declare class ClusterWorker<Data = unknown, Response = unknown> extends Abstract
|
|
|
2300
2339
|
*
|
|
2301
2340
|
* If you use a `DynamicThreadPool` the extra workers that were created will be terminated,
|
|
2302
2341
|
* but the minimum number of workers will be guaranteed.
|
|
2303
|
-
* @
|
|
2304
|
-
* @
|
|
2342
|
+
* @template Data - Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
|
|
2343
|
+
* @template Response - Type of response the worker sends back to the main thread. This can only be structured-cloneable data.
|
|
2305
2344
|
* @author [Alessandro Pio Ardizio](https://github.com/pioardi)
|
|
2306
2345
|
* @since 0.0.1
|
|
2307
2346
|
*/
|