repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into feature/task-functions
[poolifier.git]
/
src
/
pools
/
worker.ts
diff --git
a/src/pools/worker.ts
b/src/pools/worker.ts
index 52b56a2411f0f41f7c56452270b2c63be7ecd0a5..37d6308507669dd1f0ebcc295b790a1857c16a3e 100644
(file)
--- a/
src/pools/worker.ts
+++ b/
src/pools/worker.ts
@@
-132,7
+132,7
@@
export interface WorkerInfo {
/**
* Worker type.
*/
/**
* Worker type.
*/
- type: WorkerType
+
readonly
type: WorkerType
/**
* Dynamic flag.
*/
/**
* Dynamic flag.
*/
@@
-144,7
+144,7
@@
export interface WorkerInfo {
/**
* Task function names.
*/
/**
* Task function names.
*/
- taskFunctions?: string[]
+ taskFunction
Name
s?: string[]
}
/**
}
/**
@@
-171,6
+171,15
@@
export interface WorkerUsage {
readonly elu: EventLoopUtilizationMeasurementStatistics
}
readonly elu: EventLoopUtilizationMeasurementStatistics
}
+/**
+ * Worker choice strategy data.
+ *
+ * @internal
+ */
+export interface StrategyData {
+ virtualTaskEndTimestamp?: number
+}
+
/**
* Worker interface.
*/
/**
* Worker interface.
*/
@@
-199,6
+208,14
@@
export interface IWorker {
readonly once: (event: 'exit', handler: ExitHandler<this>) => void
}
readonly once: (event: 'exit', handler: ExitHandler<this>) => void
}
+/**
+ * Worker node event callback.
+ *
+ * @param workerId - The worker id.
+ * @internal
+ */
+export type WorkerNodeEventCallback = (workerId: number) => void
+
/**
* Worker node interface.
*
/**
* Worker node interface.
*
@@
-216,13
+233,18
@@
export interface IWorkerNode<Worker extends IWorker, Data = unknown> {
*/
readonly info: WorkerInfo
/**
*/
readonly info: WorkerInfo
/**
- *
Message channel (worker_threads only)
.
+ *
Worker usage statistics
.
*/
*/
- readonly
messageChannel?: MessageChannel
+ readonly
usage: WorkerUsage
/**
/**
- * Worker usage statistics.
+ * Worker choice strategy data.
+ * This is used to store data that is specific to the worker choice strategy.
+ */
+ strategyData?: StrategyData
+ /**
+ * Message channel (worker_threads only).
*/
*/
- usage: WorkerUsage
+ readonly messageChannel?: MessageChannel
/**
* Tasks queue back pressure size.
* This is the number of tasks that can be enqueued before the worker node has back pressure.
/**
* Tasks queue back pressure size.
* This is the number of tasks that can be enqueued before the worker node has back pressure.
@@
-230,16
+252,12
@@
export interface IWorkerNode<Worker extends IWorker, Data = unknown> {
tasksQueueBackPressureSize: number
/**
* Callback invoked when worker node tasks queue is back pressured.
tasksQueueBackPressureSize: number
/**
* Callback invoked when worker node tasks queue is back pressured.
- *
- * @param workerId - The worker id.
*/
*/
- onBackPressure?:
(workerId: number) => void
+ onBackPressure?:
WorkerNodeEventCallback
/**
* Callback invoked when worker node tasks queue is empty.
/**
* Callback invoked when worker node tasks queue is empty.
- *
- * @param workerId - The worker id.
*/
*/
- onEmptyQueue?:
(workerId: number) => void
+ onEmptyQueue?:
WorkerNodeEventCallback
/**
* Tasks queue size.
*
/**
* Tasks queue size.
*