Skip to content

Interface: SeizedWorker<T, R>

Defined in: streams/seize.ts:13

Interface for a worker that has been "seized" from the coroutine pool. It provides a persistent, bidirectional communication channel and a method to release the worker back to the pool.

Type Parameters

T

T = any

The type of data sent to the worker.

R

R = T

The type of data returned from the worker.

Properties

workerId

workerId: number

Defined in: streams/seize.ts:15

The unique identifier of the seized worker.


sendTask()

sendTask: (data) => Promise<R>

Defined in: streams/seize.ts:22

Sends a task to the seized worker.

Parameters

data

T

The data to be processed by the worker.

Returns

Promise<R>

A promise that resolves with the result from the worker.


release()

release: () => void

Defined in: streams/seize.ts:29

Releases the worker back to the pool. This method must be called to free up the worker for other tasks. After calling this, the sendTask method and event listeners will be defunct.

Returns

void

Released under the MIT License.