X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=c3a79eecdf9d5a71e8b0258e53321f43a4f97bbf;hb=4cb259d3e1837759b8bac901d3755f1610b5ddc4;hp=c0e3ee918ae072f071bfa33972455448b4d000b9;hpb=6be0ab6d5c78c8e91cc4668d3d03db95f15cbfab;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index c0e3ee91..c3a79eec 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,13 +1,13 @@ -
Reference to the main worker.
+https://nodejs.org/api/errors.html#class-error If the main worker is not set.
+Protected
handlePrivate
getProtected
handleGets the task function in the given scope.
+Handles a kill message sent by the main worker.
Optional
name: stringName of the function that will be returned.
+The kill message.
Protected
handleProtected
Abstract
handleHandles an error and convert it to a string so it can be sent back to the main worker.
+Handles the ready message sent by the main worker.
Checks if the worker has a task function with the given name.
+The name of the task function to check.
Message of the error.
+Whether the worker has a task function with the given name or not.
+ +https://nodejs.org/api/errors.html#class-typeerror If the name
parameter is not a string or an empty string.
Protected
messageRemoves a task function from the worker.
+The name of the task function to remove.
+Whether the task function existed and was removed or not.
+ +https://nodejs.org/api/errors.html#class-typeerror If the name
parameter is not a string or an empty string.
https://nodejs.org/api/errors.html#class-error If the name
parameter is the default task function reserved name.
https://nodejs.org/api/errors.html#class-error If the name
parameter is the task function used as default task function.
Protected
runRuns the given task.
+The task to execute.
+https://nodejs.org/api/errors.html#class-error If the task function is not found.
+Protected
runRuns the given function asynchronously.
+Runs the given task function asynchronously.
Function that will be executed.
+Task function that will be executed.
Protected
runRuns the given function synchronously.
+Runs the given task function synchronously.
Function that will be executed.
+Task function that will be executed.
Protected
sendProtected
Abstract
sendSends a message to the main worker.
+Sends a message to main worker.
The response message.
Sets the default task function to use in the worker.
+The name of the task function to use as default task function.
+Whether the default task function was set or not.
+ +https://nodejs.org/api/errors.html#class-typeerror If the name
parameter is not a string or an empty string.
https://nodejs.org/api/errors.html#class-error If the name
parameter is the default task function reserved name.
https://nodejs.org/api/errors.html#class-error If the name
parameter is a non-existing task function.
Private
startPrivate
stopPrivate
updateStatic
bindGenerated using TypeDoc
Generated using TypeDoc
Type of data this worker receives from pool's execution. This can only be serializable data.
+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 worker. This can only be serializable data.
+Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
-
+Index
Index
Constructors
-Properties
-Methods
-Constructors
constructor
+constructor
-- new
Abstract Worker<MainWorker, Data, Response>(type, isMain, taskFunctions, mainWorker, opts?): AbstractWorker<MainWorker, Data, Response>
+- new
Abstract Worker<MainWorker, Data, Response>(type, isMain, mainWorker, taskFunctions, opts?): AbstractWorker<MainWorker, Data, Response>
-
@@ -101,7 +117,7 @@
-
-
+
-
-
@@ -120,17 +136,17 @@
Constructs a new poolifier worker.
Type Parameters
MainWorker extends Worker | MessagePort
MainWorker extends MessagePort | Worker
Data = unknown
taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
-Task function(s) processed by the worker when the pool's
+execution
function is invoked. The first function is the default function.mainWorker: MainWorker
+Reference to main worker.
mainWorker: undefined | null | MainWorker
-Reference to main worker.
+taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
+Task function(s) processed by the worker when the pool's
execution
function is invoked. The first function is the default function.opts: WorkerOptions = ...
+opts: WorkerOptions = DEFAULT_WORKER_OPTIONS
Options for the worker.
Properties
- Interval
-Protected
Optional
Readonly
aliveHandler id of the
+aliveInterval
worker alive check. Interval
+Protected
Optional
activeHandler id of the
+activeInterval
worker activity check.
+Protected
Abstract
idWorker id.
Protected
Readonly
isProtected
last Worker
-Protected
main Worker
+Private
Readonly
mainReference to main worker.
-Protected
Readonly
opts
+Protected
optsOptions for the worker.
Protected
statisticsPerformance statistics computation.
+Performance statistics computation requirements.
Functions
-Protected
taskTask function(s) processed by the worker when the pool's
execution
function is invoked.Methods
+add Task Function
++- add
Task Function(name, fn): boolean
+-
+
+
+
+
+
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.
+Returns boolean
Whether the task function was added or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-error If the
+ +name
parameter is the default task function reserved name.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+fn
parameter is not a function.async Id
@@ -209,15 +265,20 @@
Private
begin-- begin
Task Performance(): TaskPerformance
+- begin
Task Performance(name?): TaskPerformance
-
+
+
Parameters
++-
+
Optional
name: stringReturns TaskPerformance
bind
@@ -244,18 +305,60 @@
Alive
-Protected
check-- check
Alive(): void
+- Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:283
Active
+Private
check+- check
Active(): void
-
Checks if the worker should be terminated, because its living too long.
Returns void
Message Worker Id
+Private
check+- check
Message Worker Id(message): void
+-
+
+
+
+
+
Check if the message worker id is set and matches the worker id.
+Parameters
++-
+
+
message: MessageValue<Data, unknown>
+The message to check.
+Returns void
+Throws
https://nodejs.org/api/errors.html#class-error If the message worker id is not set or does not match the worker id.
+ Statistics
+Private
check+- check
Statistics(): void
+-
+
Returns void
Task Function Name
+Private
check+- check
Task Function Name(name): void
+-
+
+
+
Parameters
++-
+
name: string
Returns void
Private
check@@ -267,14 +370,29 @@-
-
Parameters
taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
+taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
The task function(s) parameter that should be checked.
Returns void
Valid Task Function
+Private
check+- check
Valid Task Function(name, fn): void
+-
+
+
+
Parameters
++-
+
+-
+
name: string
fn: TaskFunction<Data, Response>
Returns void
Private
check@@ -287,7 +405,7 @@
opts: WorkerOptions
Returns void
emit Destroy
@@ -303,7 +421,7 @@ never be called.
Private
end@@ -316,7 +434,7 @@ never be called.
taskPerformance: TaskPerformance
Returns TaskPerformance
Protected
get@@ -326,48 +444,103 @@ never be called.