Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
class ThreadWorker
extends AbstractWorker<WorkerGlobalScope & globalThis, Data, Response>
import { ThreadWorker } from "https://deno.land/x/poolifier@v0.3.14/src/worker/thread-worker.ts";

A thread worker used by a poolifier ThreadPool.

When this worker is inactive for more than the given maxInactiveTime, it will send a termination request to its main thread.

If you use a DynamicThreadPool the extra workers that were created will be terminated, but the minimum number of workers will be guaranteed.

Constructors

new
ThreadWorker(taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>, opts?: WorkerOptions)

Constructs a new poolifier thread worker.

Type Parameters

optional
Data = unknown
optional
Response = unknown

Properties

private
optional
port: MessagePort

Message port used to communicate with the main worker.

protected
readonly
sendToMainWorker: (message: MessageValue<Response>) => void
optional
id: string

Methods

protected
handleError(error: Error | string): string
protected
handleKillMessage(message: MessageValue<Data>): void
protected
handleReadyMessageEvent(messageEvent: MessageEvent<MessageValue<Data>>): void