Saltar al contenido principal

Function: useRunPool()

useRunPool<TInput, TOutput>(key, data): Promise<TOutput>

Defined in: src/infrastructure/worker/worker.service.ts:185

Runs a task on an existing Worker pool. Tasks are correlated by __taskId so concurrent tasks do not stomp each other's handlers.

Type Parameters

TInput

TInput

Input data type.

TOutput

TOutput

Output data type.

Parameters

key

string

The pool key created via useCreatePool.

data

TInput

The input data to pass to the pool's function.

Returns

Promise<TOutput>

A Promise resolving to the function's output.

Throws

If the pool does not exist.

Example

useCreatePool("math", (n: number) => n * 10);
const result = await useRunPool("math", 5); // 50