X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2Fthreadworker.html;fp=docs%2Fclasses%2Fthreadworker.html;h=08ea47f802c60dc01819515f142c1b0b3c821dc3;hb=aa4307c339b5e1b49c04bcbaee597f48830b1f12;hp=60bd61710c53494e310b1b10ba7d7de550dc68fc;hpb=4f4ae1cb3c33228a023ea599c2648268d15e6c0f;p=poolifier.git diff --git a/docs/classes/threadworker.html b/docs/classes/threadworker.html index 60bd6171..08ea47f8 100644 --- a/docs/classes/threadworker.html +++ b/docs/classes/threadworker.html @@ -8,15 +8,15 @@ but the minimum number of workers will be guaranteed.
of response the worker sends back to the main thread. This can only be serializable data.
0.0.1
-
Type parameters
Data = unknown
Response = unknown
Hierarchy
Index
Constructors
Properties
Methods
Constructors
constructor
Constructs a new poolifier thread worker.
Type parameters
Data = unknown
Response = unknown
Parameters
fn: (data: Data) => Response
Function processed by the worker when the pool's
execution
function is invoked.Parameters
data: Data
Returns Response
opts: WorkerOptions = {}
Options for the worker.
-Returns ThreadWorker<Data, Response>
Properties
Protected Optional Readonly alive Interval
Returns ThreadWorker<Data, Response>
Properties
Protected Optional Readonly alive Interval
Handler Id of the
-aliveInterval
worker alive check.Protected last Task Timestamp
Protected last Task Timestamp
Timestamp of the last task processed by this worker.
Protected main Worker
Readonly opts
Methods
async Id
Returns number
The unique
asyncId
assigned to the resource.bind
AsyncResource
to which the function is bound.v14.8.0, v12.19.0
Type parameters
Func: (...args: any[]) => any
Parameters
fn: Func
The function to bind to the current
-AsyncResource
.Returns Func & { asyncResource: AsyncResource }
Protected check Alive
Returns Func & { asyncResource: AsyncResource }
Protected check Alive
Check to see if the worker should be terminated, because its living too long.
Returns void
emit Destroy
Call all
destroy
hooks. This should only ever be called once. An error will @@ -34,21 +34,21 @@ be thrown if it is called more than once. This must be manually the resource is left to be collected by the GC then thedestroy
hooks will never be called.Returns ThreadWorker<Data, Response>
A reference to
-asyncResource
.Protected get Main Worker
Protected get Main Worker
Returns the main worker.
Returns MessagePort
Reference to the main worker.
-Protected handle Error
Protected handle Error
Handle an error and convert it to a string so it can be sent back to the main worker.
Parameters
e: string | Error
The error raised by the worker.
Returns string
Message of the error.
-Protected run
Protected run
Run the given function synchronously.
Parameters
fn: (data?: Data) => Response
Function that will be executed.
Parameters
Optional data: Data
Returns Response
value: MessageValue<Data, unknown>
Input data for the given function.
-Returns void
Protected run Async
Returns void
Protected run Async
Run the given function asynchronously.
Parameters
fn: (data?: Data) => Promise<Response>
Function that will be executed.
@@ -66,7 +66,7 @@ then restore the original execution context.The receiver to be used for the function call.
Rest ...args: any[]
Optional arguments to pass to the function.
-Returns Result
Protected send To Main Worker
Returns Result
Protected send To Main Worker
Send a message to the main worker.
Parameters
message: MessageValue<Response, unknown>
The response message.