X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FAbstractWorker.html;h=c30213be0d2353c687b6bb3031da0c274838b6d8;hb=896624ae5d3cb6861b202a4c3b1d4c42368868c5;hp=1fd27753c6e6db566fbd47da1397a4362f89be3e;hpb=b4e93467358d93166716dc6e5075d58c18c961c7;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 1fd27753..c30213be 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,8 +1,8 @@ -
Abstract
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.
-Private
startPrivate
stopPrivate
updateStatic
bindBinds the given function to the current execution context.
+Private
startPrivate
stopPrivate
updateStatic
bindBinds the given function to the current execution context.
The function to bind to the current execution context.
Optional
type: stringAn optional name to associate with the underlying AsyncResource
.
Optional
thisArg: ThisArgv14.8.0, v12.19.0
-Generated using TypeDoc
Generated using TypeDoc
Base class that implements some shared logic for all poolifier workers.
+- Preparing search index...
- The search index is not available
poolifier - v3.0.9Class AbstractWorker<MainWorker, Data, Response>
Abstract
Base class that implements some shared logic for all poolifier workers.
Type Parameters
MainWorker extends Worker | MessagePort
Type of main worker.
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 worker. This can only be structured-cloneable data.
-Hierarchy
Index
Constructors
Hierarchy
Index
Constructors
Properties
Constructors
constructor
Constructs a new poolifier worker.
+Constructors
constructor
Constructs a new poolifier worker.
Type Parameters
MainWorker extends MessagePort | Worker
Data = unknown
Response = unknown
Parameters
type: string
The type of async event.
isMain: boolean
Whether this is the main worker or not.
mainWorker: 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 = DEFAULT_WORKER_OPTIONS
Options for the worker.
-Returns AbstractWorker<MainWorker, Data, Response>
Properties
Protected
Optional
activeHandler id of the
-activeInterval
worker activity check.Protected
Abstract
idWorker id.
-Protected
Readonly
isWhether this is the main worker or not.
-Protected
lastTimestamp of the last task processed by this worker.
-Private
Readonly
mainReference to main worker.
-Protected
optsOptions for the worker.
-Protected
statisticsPerformance statistics computation requirements.
-Protected
taskTask function(s) processed by the worker when the pool's
-execution
function is invoked.Methods
add Task Function
Adds a task function to the worker. +
Returns AbstractWorker<MainWorker, Data, Response>
Properties
Protected
Optional
activeHandler id of the
+activeInterval
worker activity check.Protected
Abstract
idWorker id.
+Protected
Readonly
isWhether this is the main worker or not.
+Protected
lastTimestamp of the last task processed by this worker.
+Private
Readonly
mainReference to main worker.
+Protected
optsOptions for the worker.
+Protected
statisticsPerformance statistics computation requirements.
+Protected
taskTask function(s) processed by the worker when the pool's
+execution
function is invoked.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.
Returns TaskFunctionOperationResult
Whether the task function was added or not.
-async Id
Returns number
The unique
-asyncId
assigned to the resource.Private
beginParameters
Optional
name: stringReturns TaskPerformance
bind
Binds the given function to execute to this
+AsyncResource
's scope.async Id
Returns number
The unique
+asyncId
assigned to the resource.Private
beginParameters
Optional
name: stringReturns TaskPerformance
bind
Binds the given function to execute to this
AsyncResource
's scope.Type Parameters
Func extends ((...args) => any)
Parameters
fn: Func
The function to bind to the current
AsyncResource
.Returns Func
Since
v14.8.0, v12.19.0
-Private
checkChecks if the worker should be terminated, because its living too long.
-Returns void
Private
checkCheck if the message worker id is set and matches the worker id.
+Private
checkChecks if the worker should be terminated, because its living too long.
+Returns void
Private
checkCheck 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.
-Private
checkReturns void
Private
checkChecks if the
+taskFunctions
parameter is passed to the constructor and valid.Private
checkReturns void
Private
checkChecks if the
taskFunctions
parameter is passed to the constructor and valid.Parameters
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
The task function(s) parameter that should be checked.
-Returns void
Private
checkParameters
opts: WorkerOptions
Returns void
emit Destroy
Call all
destroy
hooks. This should only ever be called once. An error will +Returns void
Private
checkParameters
opts: WorkerOptions
Returns void
emit Destroy
Call all
destroy
hooks. This should only ever be called once. An error will be thrown if it is called more than once. This must be manually called. If the resource is left to be collected by the GC then thedestroy
hooks will never be called.Returns AbstractWorker<MainWorker, Data, Response>
A reference to
-asyncResource
.Private
endParameters
taskPerformance: TaskPerformance
Returns TaskPerformance
Protected
getReturns the main worker.
+Private
endParameters
taskPerformance: TaskPerformance
Returns TaskPerformance
Protected
getReturns the main worker.
Returns MainWorker
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.
+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
Abstract
handleHandles the ready message sent by the main worker.
+Protected
handleHandles a kill message sent by the main worker.
+Parameters
_message: MessageValue<Data, unknown>
Returns void
Protected
Abstract
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.
+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.
+Protected
messageWorker message listener.
Parameters
message: MessageValue<Data, unknown>
The received message.
-Returns void
remove Task Function
Removes a task function from the worker.
+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
runRuns the given task.
+Protected
runRuns the given task.
Parameters
task: Task<Data>
The task to execute.
-Returns void
Protected
runRuns the given task function asynchronously.
+Returns void
Protected
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
run In Async Scope
Call the provided function with the provided arguments in the execution context +
Returns void
run In Async Scope
Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks before callbacks, call the function, trigger the AsyncHooks after callbacks, and then restore the original execution context.
@@ -109,20 +109,20 @@ then restore the original execution context.Parameters
this: This
Rest
...args: any[]Returns Result
Optional
thisArg: ThisThe receiver to be used for the function call.
Rest
...args: any[]Optional arguments to pass to the function.
Returns Result
Since
v9.6.0
-Protected
runRuns the given task function synchronously.
+Protected
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
Abstract
sendSends a message to main worker.
+Returns void
Protected
sendSends task function names to the main worker.
+Returns void
Protected
Abstract
sendSends a message to main worker.
Parameters
message: MessageValue<Response, Data>
The response message.
-Returns void
set Default Task Function
Sets the default task function to use in the worker.
+Returns void