Type Alias: Coroutine<T, R> 
Coroutine<
T,R> =Operator<T,R> &object
Defined in: operators/coroutine.ts:53
Type Declaration 
assignTask() 
assignTask: (
workerId,data) =>Promise<R>
Assigns a task to a specific worker in the pool.
Parameters 
workerId 
number
The ID of the worker to which the task will be assigned.
data 
T
The input data for the task.
Returns 
Promise<R>
A Promise that resolves with the result of the task.
processTask() 
processTask: (
data) =>Promise<R>
Processes a task by assigning it to the next available worker in the pool. This is the primary method for offloading work.
Parameters 
data 
T
The input data for the task.
Returns 
Promise<R>
A Promise that resolves with the result of the task.
getIdleWorker() 
getIdleWorker: () =>
Promise<{worker:Worker;workerId:number; }>
Retrieves a worker from the pool that is ready to accept a new task. If no workers are available, a new one may be created, up to a maximum limit.
Returns 
Promise<{ worker: Worker; workerId: number; }>
A Promise that resolves with an object containing the worker and its ID.
returnWorker() 
returnWorker: (
workerId) =>void
Returns a worker to the pool, making it available for subsequent tasks.
Parameters 
workerId 
number
The ID of the worker to return.
Returns 
void
finalize() 
finalize: () =>
Promise<void>
Terminates all active workers and cleans up all related resources, including the object URL for the worker script.
Returns 
Promise<void>
A Promise that resolves when all cleanup is complete.
Type Parameters 
T 
T = any
R 
R = T
Extended Operator that manages a pool of Web Workers for concurrent task processing.