8ff6b37495773eb2811905ebe267944f6f1751db
[poolifier.git] / docs / classes / AbstractWorker.html
1 <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>AbstractWorker | poolifier</title><meta name="description" content="Documentation for poolifier"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">poolifier</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">poolifier</a></li><li><a href="AbstractWorker.html">AbstractWorker</a></li></ul><h1>Class AbstractWorker&lt;MainWorker, Data, Response&gt;</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
2 <p>Base class containing some shared logic for all poolifier workers.</p>
3 </div></div></section><section class="tsd-panel tsd-type-parameters"><h3>Type parameters</h3><ul class="tsd-type-parameters"><li><h4>MainWorker<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Worker</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MessagePort</span></h4><div class="tsd-comment tsd-typography"><div class="lead">
4 <p>Type of main worker.</p>
5 </div></div></li><li><h4>Data = <span class="tsd-signature-type">unknown</span></h4><div class="tsd-comment tsd-typography"><div class="lead">
6 <p>Type of data this worker receives from pool&#39;s execution. This can only be serializable data.</p>
7 </div></div></li><li><h4>Response = <span class="tsd-signature-type">unknown</span></h4><div class="tsd-comment tsd-typography"><div class="lead">
8 <p>Type of response the worker sends back to the main worker. This can only be serializable data.</p>
9 </div></div></li></ul></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="tsd-signature-type">AsyncResource</span><ul class="tsd-hierarchy"><li><span class="target">AbstractWorker</span><ul class="tsd-hierarchy"><li><a href="ClusterWorker.html" class="tsd-signature-type" data-tsd-kind="Class">ClusterWorker</a></li><li><a href="ThreadWorker.html" class="tsd-signature-type" data-tsd-kind="Class">ThreadWorker</a></li></ul></li></ul></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-overwrite"><a href="AbstractWorker.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#aliveInterval" class="tsd-kind-icon">alive<wbr/>Interval</a></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#lastTaskTimestamp" class="tsd-kind-icon">last<wbr/>Task<wbr/>Timestamp</a></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#mainWorker" class="tsd-kind-icon">main<wbr/>Worker</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="AbstractWorker.html#opts" class="tsd-kind-icon">opts</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#asyncId" class="tsd-kind-icon">async<wbr/>Id</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#bind" class="tsd-kind-icon">bind</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#checkAlive" class="tsd-kind-icon">check<wbr/>Alive</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="AbstractWorker.html#checkFunctionInput" class="tsd-kind-icon">check<wbr/>Function<wbr/>Input</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="AbstractWorker.html#checkWorkerOptions" class="tsd-kind-icon">check<wbr/>Worker<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#emitDestroy" class="tsd-kind-icon">emit<wbr/>Destroy</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#getMainWorker" class="tsd-kind-icon">get<wbr/>Main<wbr/>Worker</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#handleError" class="tsd-kind-icon">handle<wbr/>Error</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#run" class="tsd-kind-icon">run</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#runAsync" class="tsd-kind-icon">run<wbr/>Async</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#runInAsyncScope" class="tsd-kind-icon">run<wbr/>In<wbr/>Async<wbr/>Scope</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#sendToMainWorker" class="tsd-kind-icon">send<wbr/>To<wbr/>Main<wbr/>Worker</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#triggerAsyncId" class="tsd-kind-icon">trigger<wbr/>Async<wbr/>Id</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"><a href="AbstractWorker.html#bind-1" class="tsd-kind-icon">bind</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-overwrite"><a id="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-overwrite"><li class="tsd-signature tsd-kind-icon">new <wbr/>Abstract<wbr/>Worker<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, isMain<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span>, fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span>, mainWorker<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span>, opts<span class="tsd-signature-symbol">?: </span><a href="../interfaces/WorkerOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="AbstractWorker.html" class="tsd-signature-type" data-tsd-kind="Class">AbstractWorker</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Overrides AsyncResource.constructor</p><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L42">src/worker/abstract-worker.ts:42</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
10 <p>Constructs a new poolifier worker.</p>
11 </div></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>MainWorker<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Worker</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MessagePort</span></h4></li><li><h4>Data = <span class="tsd-signature-type">unknown</span></h4></li><li><h4>Response = <span class="tsd-signature-type">unknown</span></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>type: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
12 <p>The type of async event.</p>
13 </div></div></li><li><h5>isMain: <span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
14 <p>Whether this is the main worker or not.</p>
15 </div></div></li><li><h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
16 <p>Function processed by the worker when the pool&#39;s <code>execution</code> function is invoked.</p>
17 </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>data: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h4></li></ul></li></ul></li><li><h5>mainWorker: <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
18 <p>Reference to main worker.</p>
19 </div></div></li><li><h5>opts: <a href="../interfaces/WorkerOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a><span class="tsd-signature-symbol"> = ...</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
20 <p>Options for the worker.</p>
21 </div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="AbstractWorker.html" class="tsd-signature-type" data-tsd-kind="Class">AbstractWorker</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a id="aliveInterval" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagOptional">Optional</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> alive<wbr/>Interval</h3><div class="tsd-signature tsd-kind-icon">alive<wbr/>Interval<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">Timeout</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L31">src/worker/abstract-worker.ts:31</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
22 <p>Handler Id of the <code>aliveInterval</code> worker alive check.</p>
23 </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a id="lastTaskTimestamp" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> last<wbr/>Task<wbr/>Timestamp</h3><div class="tsd-signature tsd-kind-icon">last<wbr/>Task<wbr/>Timestamp<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L27">src/worker/abstract-worker.ts:27</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
24 <p>Timestamp of the last task processed by this worker.</p>
25 </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a id="mainWorker" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> main<wbr/>Worker</h3><div class="tsd-signature tsd-kind-icon">main<wbr/>Worker<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="opts" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagReadonly">Readonly</span> opts</h3><div class="tsd-signature tsd-kind-icon">opts<span class="tsd-signature-symbol">:</span> <a href="../interfaces/WorkerOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a><span class="tsd-signature-symbol"> = ...</span></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a id="asyncId" class="tsd-anchor"></a><h3>async<wbr/>Id</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><li class="tsd-signature tsd-kind-icon">async<wbr/>Id<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.asyncId</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:315</li></ul></aside><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>The unique <code>asyncId</code> assigned to the resource.</p>
26 </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a id="bind" class="tsd-anchor"></a><h3>bind</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><li class="tsd-signature tsd-kind-icon">bind<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>asyncResource<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncResource</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.bind</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:288</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
27 <p>Binds the given function to execute to this <code>AsyncResource</code>&#39;s scope.</p>
28 </div><div><p>The returned function will have an <code>asyncResource</code> property referencing
29 the <code>AsyncResource</code> to which the function is bound.</p>
30 </div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v14.8.0, v12.19.0</p>
31 </dd></dl></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>Func<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">any</span></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
32 <p>The function to bind to the current <code>AsyncResource</code>.</p>
33 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>asyncResource<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncResource</span><span class="tsd-signature-symbol"> }</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="checkAlive" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> check<wbr/>Alive</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">check<wbr/>Alive<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L133">src/worker/abstract-worker.ts:133</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
34 <p>Check to see if the worker should be terminated, because its living too long.</p>
35 </div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private"><a id="checkFunctionInput" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagPrivate">Private</span> check<wbr/>Function<wbr/>Input</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private"><li class="tsd-signature tsd-kind-icon">check<wbr/>Function<wbr/>Input<span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L107">src/worker/abstract-worker.ts:107</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
36 <p>Check if the <code>fn</code> parameter is passed to the constructor.</p>
37 </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
38 <p>The function that should be defined.</p>
39 </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>data: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private"><a id="checkWorkerOptions" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagPrivate">Private</span> check<wbr/>Worker<wbr/>Options</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private"><li class="tsd-signature tsd-kind-icon">check<wbr/>Worker<wbr/>Options<span class="tsd-signature-symbol">(</span>opts<span class="tsd-signature-symbol">: </span><a href="../interfaces/WorkerOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L92">src/worker/abstract-worker.ts:92</a></li></ul></aside><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>opts: <a href="../interfaces/WorkerOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a id="emitDestroy" class="tsd-anchor"></a><h3>emit<wbr/>Destroy</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><li class="tsd-signature tsd-kind-icon">emit<wbr/>Destroy<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="AbstractWorker.html" class="tsd-signature-type" data-tsd-kind="Class">AbstractWorker</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.emitDestroy</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:311</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
40 <p>Call all <code>destroy</code> hooks. This should only ever be called once. An error will
41 be thrown if it is called more than once. This <strong>must</strong> be manually called. If
42 the resource is left to be collected by the GC then the <code>destroy</code> hooks will
43 never be called.</p>
44 </div></div><h4 class="tsd-returns-title">Returns <a href="AbstractWorker.html" class="tsd-signature-type" data-tsd-kind="Class">AbstractWorker</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></h4><div><p>A reference to <code>asyncResource</code>.</p>
45 </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="getMainWorker" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> get<wbr/>Main<wbr/>Worker</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">get<wbr/>Main<wbr/>Worker<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L116">src/worker/abstract-worker.ts:116</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
46 <p>Returns the main worker.</p>
47 </div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">MainWorker</span></h4><div><p>Reference to the main worker.</p>
48 </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="handleError" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> handle<wbr/>Error</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">handle<wbr/>Error<span class="tsd-signature-symbol">(</span>e<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Error</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L148">src/worker/abstract-worker.ts:148</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
49 <p>Handle an error and convert it to a string so it can be sent back to the main worker.</p>
50 </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>e: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Error</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
51 <p>The error raised by the worker.</p>
52 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div><p>Message of the error.</p>
53 </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="run" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> run</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">run<span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span>, value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L158">src/worker/abstract-worker.ts:158</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
54 <p>Run the given function synchronously.</p>
55 </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
56 <p>Function that will be executed.</p>
57 </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span></h4></li></ul></li></ul></li><li><h5>value: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
58 <p>Input data for the given function.</p>
59 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="runAsync" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> run<wbr/>Async</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">run<wbr/>Async<span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span>, value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L179">src/worker/abstract-worker.ts:179</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
60 <p>Run the given function asynchronously.</p>
61 </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
62 <p>Function that will be executed.</p>
63 </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul></li><li><h5>value: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
64 <p>Input data for the given function.</p>
65 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a id="runInAsyncScope" class="tsd-anchor"></a><h3>run<wbr/>In<wbr/>Async<wbr/>Scope</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><li class="tsd-signature tsd-kind-icon">run<wbr/>In<wbr/>Async<wbr/>Scope<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">This</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span>, thisArg<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">This</span>, <span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.runInAsyncScope</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:303</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
66 <p>Call the provided function with the provided arguments in the execution context
67 of the async resource. This will establish the context, trigger the AsyncHooks
68 before callbacks, call the function, trigger the AsyncHooks after callbacks, and
69 then restore the original execution context.</p>
70 </div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v9.6.0</p>
71 </dd></dl></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>This</h4></li><li><h4>Result</h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
72 <p>The function to call in the execution context of this async resource.</p>
73 </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal tsd-is-external"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagRest">Rest</span> <span class="tsd-signature-symbol">...</span>args: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span></h4></li></ul></li></ul></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> thisArg: <span class="tsd-signature-type" data-tsd-kind="Type parameter">This</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
74 <p>The receiver to be used for the function call.</p>
75 </div></div></li><li><h5><span class="tsd-flag ts-flagRest">Rest</span> <span class="tsd-signature-symbol">...</span>args: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
76 <p>Optional arguments to pass to the function.</p>
77 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Result</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a id="sendToMainWorker" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagAbstract">Abstract</span> send<wbr/>To<wbr/>Main<wbr/>Worker</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected"><li class="tsd-signature tsd-kind-icon">send<wbr/>To<wbr/>Main<wbr/>Worker<span class="tsd-signature-symbol">(</span>message<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0136f64/src/worker/abstract-worker.ts#L128">src/worker/abstract-worker.ts:128</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
78 <p>Send a message to the main worker.</p>
79 </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>message: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Response</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
80 <p>The response message.</p>
81 </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a id="triggerAsyncId" class="tsd-anchor"></a><h3>trigger<wbr/>Async<wbr/>Id</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><li class="tsd-signature tsd-kind-icon">trigger<wbr/>Async<wbr/>Id<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.triggerAsyncId</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:320</li></ul></aside><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>The same <code>triggerAsyncId</code> that is passed to the <code>AsyncResource</code> constructor.</p>
82 </div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"><a id="bind-1" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagStatic">Static</span> bind</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"><li class="tsd-signature tsd-kind-icon">bind<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">ThisArg</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span>, type<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, thisArg<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">ThisArg</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>asyncResource<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncResource</span><span class="tsd-signature-symbol"> }</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from AsyncResource.bind</p><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:273</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
83 <p>Binds the given function to the current execution context.</p>
84 </div><div><p>The returned function will have an <code>asyncResource</code> property referencing
85 the <code>AsyncResource</code> to which the function is bound.</p>
86 </div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v14.8.0, v12.19.0</p>
87 </dd></dl></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>Func<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>args<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">any</span></h4></li><li><h4>ThisArg</h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
88 <p>The function to bind to the current execution context.</p>
89 </div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> type: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
90 <p>An optional name to associate with the underlying <code>AsyncResource</code>.</p>
91 </div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> thisArg: <span class="tsd-signature-type" data-tsd-kind="Type parameter">ThisArg</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">Func</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>asyncResource<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncResource</span><span class="tsd-signature-symbol"> }</span></h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-class tsd-has-type-parameter"><a href="AbstractWorker.html" class="tsd-kind-icon">Abstract<wbr/>Worker</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-overwrite"><a href="AbstractWorker.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#aliveInterval" class="tsd-kind-icon">alive<wbr/>Interval</a></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#lastTaskTimestamp" class="tsd-kind-icon">last<wbr/>Task<wbr/>Timestamp</a></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#mainWorker" class="tsd-kind-icon">main<wbr/>Worker</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="AbstractWorker.html#opts" class="tsd-kind-icon">opts</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#asyncId" class="tsd-kind-icon">async<wbr/>Id</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#bind" class="tsd-kind-icon">bind</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#checkAlive" class="tsd-kind-icon">check<wbr/>Alive</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="AbstractWorker.html#checkFunctionInput" class="tsd-kind-icon">check<wbr/>Function<wbr/>Input</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="AbstractWorker.html#checkWorkerOptions" class="tsd-kind-icon">check<wbr/>Worker<wbr/>Options</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#emitDestroy" class="tsd-kind-icon">emit<wbr/>Destroy</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#getMainWorker" class="tsd-kind-icon">get<wbr/>Main<wbr/>Worker</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#handleError" class="tsd-kind-icon">handle<wbr/>Error</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#run" class="tsd-kind-icon">run</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#runAsync" class="tsd-kind-icon">run<wbr/>Async</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#runInAsyncScope" class="tsd-kind-icon">run<wbr/>In<wbr/>Async<wbr/>Scope</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="AbstractWorker.html#sendToMainWorker" class="tsd-kind-icon">send<wbr/>To<wbr/>Main<wbr/>Worker</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="AbstractWorker.html#triggerAsyncId" class="tsd-kind-icon">trigger<wbr/>Async<wbr/>Id</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"><a href="AbstractWorker.html#bind-1" class="tsd-kind-icon">bind</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>