Function: useCreatePool()
useCreatePool<
TInput,TOutput>(key,workerFunc):void
Defined in: src/infrastructure/worker/worker.service.ts:123
Creates a reusable Worker pool under a unique key. If a pool with the same key already exists, it is terminated first.
Type Parameters
TInput
TInput
Input data type.
TOutput
TOutput
Output data type.
Parameters
key
string
A unique identifier for this pool.
workerFunc
WorkerFunc<TInput, TOutput>
The pure function the pool will execute.
Returns
void
Example
useCreatePool("heavy", (n: number) => n ** 2);
const result = await useRunPool("heavy", 9); // 81
useTerminate("heavy");