X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FThreadWorker.html;h=4b99bdacfc0d66010847fd8e3e26cae7192c3a8e;hb=36df5bd40369d98d6ccb60400e66dce1aa980d54;hp=f59e8a110eb67095ef8673b533ced25813b3d66c;hpb=04cb7adbacc7fb0d1b76db6122f86c52e33d136d;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index f59e8a11..4b99bdac 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,4 +1,4 @@ -
Protected
Optional
alive
Handler id of the
+aliveInterval
worker alive check. Interval
+Protected
Optional
activeHandler id of the
activeInterval
worker activity check.Protected
Readonly
isProtected
lastProtected
Readonly
mainProtected
Readonly
optsProtected
statisticsProtected
taskAccessors
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: WorkerFunction<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.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
@@ -268,7 +306,7 @@ never be called.
Protected
handle@@ -289,7 +327,30 @@ never be called.
has Task Function
++- has
Task Function(name): boolean
+-
+
+
+
+
+
Checks if the worker has a task function with the given name.
+Parameters
++-
+
+
name: string
+The name of the task function to check.
+Returns boolean
Whether the worker has a task function with the given name or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+name
parameter is not a string.Protected
message@@ -302,39 +363,88 @@ never be called.-
message: MessageValue<Data, Data>
-Message received.
+The received message.
Returns void
remove Task Function
++- remove
Task Function(name): boolean
+-
+
+
+
+
+
Removes a task function from the worker.
+Parameters
++-
+
+
name: string
+The name of the task function to remove.
+Returns boolean
Whether the task function existed and was removed or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a 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-error If the
+name
parameter is the task function used as default task function.
+Protected
run+- run(task): void
+-
+
+
+
+
+
Runs the given task.
+Parameters
++-
+
+
task: Task<Data>
+The task to execute.
+Returns void
+Throws
https://nodejs.org/api/errors.html#class-error If the task function is not found.
+Protected
run-- run
Async(fn, message): void
+- run
Async(fn, task): void
-
-
-
-
-
+- Defined in src/worker/abstract-worker.ts:432
Runs the given function asynchronously.
+Runs the given task function asynchronously.
Parameters
fn: WorkerAsyncFunction<Data, Response>
-Function that will be executed.
+Task function that will be executed.
message: MessageValue<Data, unknown>
-Input data for the given function.
+task: Task<Data>
+Input data for the task function.
Returns void
run In Async Scope
@@ -393,28 +503,40 @@ then restore the original execution context.
Sync
Protected
run-- run
Sync(fn, message): void
+- run
Sync(fn, task): void
-
-
-
-
-
+- Defined in src/worker/abstract-worker.ts:394
+
+
To Main Worker
+- Defined in src/worker/thread-worker.ts:56
+
+
-
-
-
Runs the given function synchronously.
+Runs the given task function synchronously.
Parameters
fn: WorkerSyncFunction<Data, Response>
-Function that will be executed.
+Task function that will be executed.
message: MessageValue<Data, unknown>
-Input data for the given function.
+task: Task<Data>
+Input data for the task function.
Returns void
Ready Response
+Protected
send+- send
Ready Response(): void
+-
+
+
Sends the ready response to the main worker.
+Returns void
+Protected
send@@ -434,7 +556,34 @@ then restore the original execution context.
set Default Task Function
++- set
Default Task Function(name): boolean
+-
+
+
+
+
+
Sets the default task function to use when no task function name is specified.
+Parameters
++-
+
+
name: string
+The name of the task function to use as default task function.
+Returns boolean
Whether the default task function was set or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a 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-error If the
+name
parameter is a non-existing task function.trigger Async Id
@@ -446,18 +595,6 @@ then restore the original execution context.- Defined in node_modules/.pnpm/@types+node@20.4.1/node_modules/@types/node/async_hooks.d.ts:311
Inherited from AbstractWorker.triggerAsyncId
Ready
-Protected
worker-- worker
Ready(): void
--
-
-
Notifies the main worker that this worker is ready to process tasks.
-Returns void
-Static
bind@@ -514,7 +651,7 @@ then restore the original execution context.
- constructor
-- alive
Interval
+- active
Interval
- is
Main
- last
Task Timestamp
- main
Worker
@@ -522,21 +659,26 @@ then restore the original execution context.
- statistics
- task
Functions
- id
+- add
Task Function
- async
Id
- bind
- emit
Destroy
- get
Main Worker
- handle
Error
+- has
Task Function
- message
Listener
+- remove
Task Function
+- run
- run
Async
- run
In Async Scope
- run
Sync
+- send
Ready Response
- send
To Main Worker
+- set
Default Task Function
- trigger
Async Id
-- worker
Ready
- bind