repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
---
[poolifier.git]
/
src
/
pools
/
worker.ts
diff --git
a/src/pools/worker.ts
b/src/pools/worker.ts
index 12a2e321b11c3724e739d0e7d9fd4fe708eb9a12..99c0d9a6feeea35815a520ff95a160d927bcc4fc 100644
(file)
--- a/
src/pools/worker.ts
+++ b/
src/pools/worker.ts
@@
-2,7
+2,7
@@
import type { EventEmitter } from 'node:events'
import type { MessageChannel, WorkerOptions } from 'node:worker_threads'
import type { CircularArray } from '../circular-array.js'
import type { MessageChannel, WorkerOptions } from 'node:worker_threads'
import type { CircularArray } from '../circular-array.js'
-import type { Task } from '../utility-types.js'
+import type { Task
, TaskFunctionProperties
} from '../utility-types.js'
/**
* Callback invoked when the worker has started successfully.
/**
* Callback invoked when the worker has started successfully.
@@
-173,9
+173,14
@@
export interface WorkerInfo {
*/
stealing: boolean
/**
*/
stealing: boolean
/**
- * Task function names.
+ * Back pressure flag.
+ * This flag is set to `true` when worker node tasks queue has back pressure.
*/
*/
- taskFunctionNames?: string[]
+ backPressure: boolean
+ /**
+ * Task functions properties.
+ */
+ taskFunctionsProperties?: TaskFunctionProperties[]
}
/**
}
/**
@@
-267,6
+272,7
@@
export interface WorkerNodeOptions {
workerOptions?: WorkerOptions
env?: Record<string, unknown>
tasksQueueBackPressureSize: number | undefined
workerOptions?: WorkerOptions
env?: Record<string, unknown>
tasksQueueBackPressureSize: number | undefined
+ tasksQueueBucketSize: number | undefined
}
/**
}
/**
@@
-317,25
+323,19
@@
export interface IWorkerNode<Worker extends IWorker, Data = unknown>
* @returns The tasks queue size.
*/
readonly enqueueTask: (task: Task<Data>) => number
* @returns The tasks queue size.
*/
readonly enqueueTask: (task: Task<Data>) => number
- /**
- * Prepends a task to the tasks queue.
- *
- * @param task - The task to prepend.
- * @returns The tasks queue size.
- */
- readonly unshiftTask: (task: Task<Data>) => number
/**
* Dequeue task.
*
/**
* Dequeue task.
*
+ * @param bucket - The prioritized bucket to dequeue from. @defaultValue 0
* @returns The dequeued task.
*/
* @returns The dequeued task.
*/
- readonly dequeueTask: () => Task<Data> | undefined
+ readonly dequeueTask: (
bucket?: number
) => Task<Data> | undefined
/**
/**
- *
Pops a task from the tasks queue
.
+ *
Dequeue last prioritized task
.
*
*
- * @returns The
popp
ed task.
+ * @returns The
dequeu
ed task.
*/
*/
- readonly
pop
Task: () => Task<Data> | undefined
+ readonly
dequeueLastPrioritized
Task: () => Task<Data> | undefined
/**
* Clears tasks queue.
*/
/**
* Clears tasks queue.
*/
@@
-346,10
+346,6
@@
export interface IWorkerNode<Worker extends IWorker, Data = unknown>
* @returns `true` if the worker node has back pressure, `false` otherwise.
*/
readonly hasBackPressure: () => boolean
* @returns `true` if the worker node has back pressure, `false` otherwise.
*/
readonly hasBackPressure: () => boolean
- /**
- * Resets usage statistics.
- */
- readonly resetUsage: () => void
/**
* Terminates the worker node.
*/
/**
* Terminates the worker node.
*/