MCPcopy Create free account
hub / github.com/andywer/threads.js / Pool

Interface Pool

src/master/pool.ts:62–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 * concurrency.
61 */
62export interface Pool<ThreadType extends Thread> {
63 /**
64 * Returns a promise that resolves once the task queue is emptied.
65 * Promise will be rejected if any task fails.
66 *
67 * @param allowResolvingImmediately Set to `true` to resolve immediately if task queue is currently empty.
68 */
69 completed(allowResolvingImmediately?: boolean): Promise<any>
70
71 /**
72 * Returns a promise that resolves once the task queue is emptied.
73 * Failing tasks will not cause the promise to be rejected.
74 *
75 * @param allowResolvingImmediately Set to `true` to resolve immediately if task queue is currently empty.
76 */
77 settled(allowResolvingImmediately?: boolean): Promise<Error[]>
78
79 /**
80 * Returns an observable that yields pool events.
81 */
82 events(): Observable<PoolEvent<ThreadType>>
83
84 /**
85 * Queue a task and return a promise that resolves once the task has been dequeued,
86 * started and finished.
87 *
88 * @param task An async function that takes a thread instance and invokes it.
89 */
90 queue<Return>(task: TaskRunFunction<ThreadType, Return>): QueuedTask<ThreadType, Return>
91
92 /**
93 * Terminate all pool threads.
94 *
95 * @param force Set to `true` to kill the thread even if it cannot be stopped gracefully.
96 */
97 terminate(force?: boolean): Promise<void>
98}
99
100export interface PoolOptions {
101 /** Maximum no. of tasks to run on one worker thread at a time. Defaults to one. */

Callers 2

testFunction · 0.85
pool.test.tsFile · 0.85

Implementers 1

WorkerPoolsrc/master/pool.ts

Calls

no outgoing calls

Tested by

no test coverage detected