X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FThreadWorker.html;h=7ff9daf4d441b0d3b996e2b97547c88b8798df64;hb=62a7baffdaf232cdaaf94b918c9b8ef43b6bfbb8;hp=5f3558ab52c635b54a92116f4d1cc776480d6e3f;hpb=f8b3d84c1c95773a1e18d2c025d89d73c4f2ab15;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index 5f3558ab..7ff9daf4 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,13 +1,13 @@ -
A thread worker used by a poolifier
+ThreadPool
.- Preparing search index...
- The search index is not available
poolifier - v3.1.14Class ThreadWorker<Data, Response>
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.Author
Alessandro Pio Ardizio
Since
0.0.1
-Type Parameters
Data = unknown
Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
-Response = unknown
Type of response the worker sends back to the main thread. This can only be structured-cloneable data.
-Hierarchy
Index
Constructors
Type Parameters
Data = unknown
Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
+Response = unknown
Type of response the worker sends back to the main thread. This can only be structured-cloneable data.
+Hierarchy (view full)
Index
Constructors
Properties
Constructors
constructor
Constructs a new poolifier thread worker.
-Type Parameters
Data = unknown
Response = unknown
Parameters
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
Task function(s) processed by the worker when the pool's
+execution
function is invoked.Constructors
constructor
Constructs a new poolifier thread worker.
+Type Parameters
Data = unknown
Response = unknown
Parameters
taskFunctions: TaskSyncFunction<Data, Response> | TaskAsyncFunction<Data, Response> | TaskFunctions<Data, Response>
Task function(s) processed by the worker when the pool's
execution
function is invoked.opts: WorkerOptions = {}
Options for the worker.
-Returns ThreadWorker<Data, Response>
Properties
Protected
Optional
activeHandler id of the
-activeInterval
worker activity check.Protected
Readonly
isWhether this is the main worker or not.
-Protected
lastTimestamp of the last task processed by this worker.
-Protected
optsOptions for the worker.
-Private
Optional
portMessage port used to communicate with the main worker.
-Protected
statisticsPerformance statistics computation requirements.
-Protected
taskTask function(s) processed by the worker when the pool's
-execution
function is invoked.Accessors
Protected
idWorker id.
-Returns number
Methods
add Task Function
Adds a task function to the worker. +
Returns ThreadWorker<Data, Response>
Properties
Protected
Optional
activeHandler id of the
+activeInterval
worker activity check.Protected
Readonly
isWhether this is the main worker or not.
+Protected
lastTimestamp of the last task processed by this worker.
+Protected
optsOptions for the worker.
+Private
Optional
portMessage port used to communicate with the main worker.
+Protected
statisticsPerformance statistics computation requirements.
+Protected
taskTask function(s) processed by the worker when the pool's
+execution
function is invoked.Accessors
Protected
idWorker id.
+Returns number
Methods
add Task Function
Adds a task function to the worker. If a task function with the same name already exists, it is replaced.
Parameters
name: string
The name of the task function to add.
-fn: TaskFunction<Data, Response>
The task function to add.
+fn: TaskFunction<Data, Response>
The task function to add.
Returns TaskFunctionOperationResult
Whether the task function was added or not.
-Protected
getReturns the main worker.
-Returns MessagePort
Reference to the main worker.
+Protected
getReturns the main worker.
+Returns MessagePort
Reference to the main worker.
Throws
https://nodejs.org/api/errors.html#class-error If the main worker is not set.
-Protected
handleHandles an error and convert it to a string so it can be sent back to the main worker.
-Parameters
error: string | Error
The error raised by the worker.
+Protected
handleHandles an error and convert it to a string so it can be sent back to the main worker.
+Parameters
error: string | Error
The error raised by the worker.
Returns string
The error message.
-Protected
handleHandles a kill message sent by the main worker.
-Parameters
message: MessageValue<Data, unknown>
Returns void
Protected
handleHandles the ready message sent by the main worker.
-Parameters
message: MessageValue<Data, unknown>
The ready message.
-Returns void
Protected
handleParameters
message: MessageValue<Data, unknown>
Returns void
has Task Function
Checks if the worker has a task function with the given name.
+Protected
handleHandles a kill message sent by the main worker.
+Parameters
message: MessageValue<Data, unknown>
Returns void
Protected
handleHandles the ready message sent by the main worker.
+Parameters
message: MessageValue<Data, unknown>
The ready message.
+Returns void
Protected
handleParameters
message: MessageValue<Data, unknown>
Returns void
has Task Function
Checks if the worker has a task function with the given name.
Parameters
name: string
The name of the task function to check.
Returns TaskFunctionOperationResult
Whether the worker has a task function with the given name or not.
-list Task Function Names
Lists the names of the worker's task functions.
+list Task Function Names
Lists the names of the worker's task functions.
Returns string[]
The names of the worker's task functions.
-Protected
messageWorker message listener.
-Parameters
message: MessageValue<Data, unknown>
The received message.
-Returns void
remove Task Function
Removes a task function from the worker.
+Protected
messageWorker message listener.
+Parameters
message: MessageValue<Data, unknown>
The received message.
+Returns void
remove Task Function
Removes a task function from the worker.
Parameters
name: string
The name of the task function to remove.
Returns TaskFunctionOperationResult
Whether the task function existed and was removed or not.
-Protected
Readonly
runRuns the given task.
-Parameters
task: Task<Data>
The task to execute.
-Returns void
Protected
Readonly
runRuns the given task function asynchronously.
-Parameters
fn: TaskAsyncFunction<Data, Response>
Task function that will be executed.
-task: Task<Data>
Input data for the task function.
-Returns void
Protected
Readonly
runRuns the given task function synchronously.
-Parameters
fn: TaskSyncFunction<Data, Response>
Task function that will be executed.
-task: Task<Data>
Input data for the task function.
-Returns void
Protected
sendSends task function names to the main worker.
-Returns void
Protected
Readonly
sendSends a message to main worker.
-Parameters
message: MessageValue<Response, unknown>
The response message.
-Returns void
set Default Task Function
Sets the default task function to use in the worker.
+Protected
Readonly
runRuns the given task.
+Parameters
task: Task<Data>
The task to execute.
+Returns void
Protected
Readonly
runRuns the given task function asynchronously.
+Parameters
fn: TaskAsyncFunction<Data, Response>
Task function that will be executed.
+task: Task<Data>
Input data for the task function.
+Returns void
Protected
Readonly
runRuns the given task function synchronously.
+Parameters
fn: TaskSyncFunction<Data, Response>
Task function that will be executed.
+task: Task<Data>
Input data for the task function.
+Returns void
Protected
sendSends task function names to the main worker.
+Returns void
Protected
Readonly
sendSends a message to main worker.
+Parameters
message: MessageValue<Response, unknown>
The response message.
+Returns void
set Default Task Function
Sets the default task function to use in the worker.
Parameters
name: string
The name of the task function to use as default task function.
Returns TaskFunctionOperationResult
Whether the default task function was set or not.
-Settings
Member Visibility
Theme
On This Page
Generated using TypeDoc
Settings
Member Visibility
Theme
On This Page
Generated using TypeDoc