Commit | Line | Data |
---|---|---|
5ea22628 JB |
1 | <!doctype html> |
2 | <html class="default no-js"> | |
3 | <head> | |
4 | <meta charset="utf-8"> | |
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
6 | <title>ThreadWorker | poolifier</title> | |
7 | <meta name="description" content="Documentation for poolifier"> | |
8 | <meta name="viewport" content="width=device-width, initial-scale=1"> | |
9 | <link rel="stylesheet" href="../assets/css/main.css"> | |
10 | <script async src="../assets/js/search.js" id="search-script"></script> | |
11 | </head> | |
12 | <body> | |
13 | <header> | |
14 | <div class="tsd-page-toolbar"> | |
15 | <div class="container"> | |
16 | <div class="table-wrap"> | |
17 | <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base=".."> | |
18 | <div class="field"> | |
19 | <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> | |
20 | <input id="tsd-search-field" type="text" /> | |
21 | </div> | |
22 | <ul class="results"> | |
23 | <li class="state loading">Preparing search index...</li> | |
24 | <li class="state failure">The search index is not available</li> | |
25 | </ul> | |
26 | <a href="../index.html" class="title">poolifier</a> | |
27 | </div> | |
28 | <div class="table-cell" id="tsd-widgets"> | |
29 | <div id="tsd-filter"> | |
30 | <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> | |
31 | <div class="tsd-filter-group"> | |
32 | <div class="tsd-select" id="tsd-filter-visibility"> | |
33 | <span class="tsd-select-label">All</span> | |
34 | <ul class="tsd-select-list"> | |
35 | <li data-value="public">Public</li> | |
36 | <li data-value="protected">Public/Protected</li> | |
37 | <li data-value="private" class="selected">All</li> | |
38 | </ul> | |
39 | </div> | |
40 | <input type="checkbox" id="tsd-filter-inherited" checked /> | |
41 | <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> | |
42 | <input type="checkbox" id="tsd-filter-externals" checked /> | |
43 | <label class="tsd-widget" for="tsd-filter-externals">Externals</label> | |
44 | </div> | |
45 | </div> | |
46 | <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> | |
47 | </div> | |
48 | </div> | |
49 | </div> | |
50 | </div> | |
51 | <div class="tsd-page-title"> | |
52 | <div class="container"> | |
53 | <ul class="tsd-breadcrumb"> | |
54 | <li> | |
55 | <a href="../index.html">poolifier</a> | |
56 | </li> | |
57 | <li> | |
58 | <a href="threadworker.html">ThreadWorker</a> | |
59 | </li> | |
60 | </ul> | |
61 | <h1>Class ThreadWorker<Data, Response></h1> | |
62 | </div> | |
63 | </div> | |
64 | </header> | |
65 | <div class="container container-main"> | |
66 | <div class="row"> | |
67 | <div class="col-8 col-content"> | |
68 | <section class="tsd-panel tsd-comment"> | |
69 | <div class="tsd-comment tsd-typography"> | |
70 | <div class="lead"> | |
71 | <p>A thread worker used by a poolifier <code>ThreadPool</code>.</p> | |
72 | </div> | |
73 | <p>When this worker is inactive for more than the given <code>maxInactiveTime</code>, | |
74 | it will send a termination request to its main thread.</p> | |
75 | <p>If you use a <code>DynamicThreadPool</code> the extra workers that were created will be terminated, | |
76 | but the minimum number of workers will be guaranteed.</p> | |
77 | <dl class="tsd-comment-tags"> | |
78 | <dt>author</dt> | |
79 | <dd><p><a href="https://github.com/pioardi">Alessandro Pio Ardizio</a></p> | |
80 | </dd> | |
81 | <dt>since</dt> | |
82 | <dd><p>0.0.1</p> | |
83 | </dd> | |
84 | </dl> | |
85 | </div> | |
86 | </section> | |
87 | <section class="tsd-panel tsd-type-parameters"> | |
88 | <h3>Type parameters</h3> | |
89 | <ul class="tsd-type-parameters"> | |
90 | <li> | |
91 | <h4>Data = <span class="tsd-signature-type">unknown</span></h4> | |
92 | <div class="tsd-comment tsd-typography"> | |
93 | <div class="lead"> | |
94 | <p>Type of data this worker receives from pool's execution. This can only be serializable data.</p> | |
95 | </div> | |
96 | </div> | |
97 | </li> | |
98 | <li> | |
99 | <h4>Response = <span class="tsd-signature-type">unknown</span></h4> | |
100 | <div class="tsd-comment tsd-typography"> | |
101 | <div class="lead"> | |
102 | <p>Type of response the worker sends back to the main thread. This can only be serializable data.</p> | |
103 | </div> | |
104 | </div> | |
105 | </li> | |
106 | </ul> | |
107 | </section> | |
108 | <section class="tsd-panel tsd-hierarchy"> | |
109 | <h3>Hierarchy</h3> | |
110 | <ul class="tsd-hierarchy"> | |
111 | <li> | |
112 | <a href="abstractworker.html" class="tsd-signature-type" data-tsd-kind="Class">AbstractWorker</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">MessagePort</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span> | |
113 | <ul class="tsd-hierarchy"> | |
114 | <li> | |
115 | <span class="target">ThreadWorker</span> | |
116 | </li> | |
117 | </ul> | |
118 | </li> | |
119 | </ul> | |
120 | </section> | |
121 | <section class="tsd-panel-group tsd-index-group"> | |
122 | <h2>Index</h2> | |
123 | <section class="tsd-panel tsd-index-panel"> | |
124 | <div class="tsd-index-content"> | |
125 | <section class="tsd-index-section "> | |
126 | <h3>Constructors</h3> | |
127 | <ul class="tsd-index-list"> | |
128 | <li class="tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited"><a href="threadworker.html#constructor" class="tsd-kind-icon">constructor</a></li> | |
129 | </ul> | |
130 | </section> | |
131 | <section class="tsd-index-section "> | |
132 | <h3>Properties</h3> | |
133 | <ul class="tsd-index-list"> | |
134 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#async" class="tsd-kind-icon">async</a></li> | |
135 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#interval" class="tsd-kind-icon">interval</a></li> | |
136 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#killbehavior" class="tsd-kind-icon">kill<wbr>Behavior</a></li> | |
137 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#lasttask" class="tsd-kind-icon">last<wbr>Task</a></li> | |
138 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#mainworker" class="tsd-kind-icon">main<wbr>Worker</a></li> | |
139 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#maxinactivetime" class="tsd-kind-icon">max<wbr>Inactive<wbr>Time</a></li> | |
140 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><a href="threadworker.html#opts" class="tsd-kind-icon">opts</a></li> | |
141 | </ul> | |
142 | </section> | |
143 | <section class="tsd-index-section "> | |
144 | <h3>Methods</h3> | |
145 | <ul class="tsd-index-list"> | |
146 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="threadworker.html#asyncid" class="tsd-kind-icon">async<wbr>Id</a></li> | |
147 | <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="threadworker.html#bind" class="tsd-kind-icon">bind</a></li> | |
148 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#checkalive" class="tsd-kind-icon">check<wbr>Alive</a></li> | |
149 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="threadworker.html#emitdestroy" class="tsd-kind-icon">emit<wbr>Destroy</a></li> | |
150 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#getmainworker" class="tsd-kind-icon">get<wbr>Main<wbr>Worker</a></li> | |
151 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#handleerror" class="tsd-kind-icon">handle<wbr>Error</a></li> | |
152 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#run" class="tsd-kind-icon">run</a></li> | |
153 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"><a href="threadworker.html#runasync" class="tsd-kind-icon">run<wbr>Async</a></li> | |
154 | <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="threadworker.html#runinasyncscope" class="tsd-kind-icon">run<wbr>InAsync<wbr>Scope</a></li> | |
155 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-protected"><a href="threadworker.html#sendtomainworker" class="tsd-kind-icon">send<wbr>ToMain<wbr>Worker</a></li> | |
156 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"><a href="threadworker.html#triggerasyncid" class="tsd-kind-icon">trigger<wbr>Async<wbr>Id</a></li> | |
157 | <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"><a href="threadworker.html#bind-1" class="tsd-kind-icon">bind</a></li> | |
158 | </ul> | |
159 | </section> | |
160 | </div> | |
161 | </section> | |
162 | </section> | |
163 | <section class="tsd-panel-group tsd-member-group "> | |
164 | <h2>Constructors</h2> | |
165 | <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited"> | |
166 | <a name="constructor" class="tsd-anchor"></a> | |
167 | <h3>constructor</h3> | |
168 | <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited"> | |
169 | <li class="tsd-signature tsd-kind-icon">new <wbr>Thread<wbr>Worker<Data, Response><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</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Response</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="threadworker.html" class="tsd-signature-type" data-tsd-kind="Class">ThreadWorker</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span></li> | |
170 | </ul> | |
171 | <ul class="tsd-descriptions"> | |
172 | <li class="tsd-description"> | |
173 | <aside class="tsd-sources"> | |
174 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#constructor">constructor</a></p> | |
175 | <ul> | |
849e0547 | 176 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/thread-worker.ts#L25">src/worker/thread-worker.ts:25</a></li> |
5ea22628 JB |
177 | </ul> |
178 | </aside> | |
179 | <div class="tsd-comment tsd-typography"> | |
180 | <div class="lead"> | |
181 | <p>Constructs a new poolifier thread worker.</p> | |
182 | </div> | |
183 | </div> | |
184 | <h4 class="tsd-type-parameters-title">Type parameters</h4> | |
185 | <ul class="tsd-type-parameters"> | |
186 | <li> | |
187 | <h4>Data = <span class="tsd-signature-type">unknown</span></h4> | |
188 | </li> | |
189 | <li> | |
190 | <h4>Response = <span class="tsd-signature-type">unknown</span></h4> | |
191 | </li> | |
192 | </ul> | |
193 | <h4 class="tsd-parameters-title">Parameters</h4> | |
194 | <ul class="tsd-parameters"> | |
195 | <li> | |
196 | <h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Response</span></h5> | |
197 | <div class="tsd-comment tsd-typography"> | |
198 | <p>Function processed by the worker when the pool's <code>execution</code> function is invoked.</p> | |
199 | </div> | |
200 | <ul class="tsd-parameters"> | |
201 | <li class="tsd-parameter-signature"> | |
202 | <ul class="tsd-signatures tsd-kind-type-literal"> | |
203 | <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</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Response</span></li> | |
204 | </ul> | |
205 | <ul class="tsd-descriptions"> | |
206 | <li class="tsd-description"> | |
207 | <h4 class="tsd-parameters-title">Parameters</h4> | |
208 | <ul class="tsd-parameters"> | |
209 | <li> | |
210 | <h5>data: <span class="tsd-signature-type">Data</span></h5> | |
211 | </li> | |
212 | </ul> | |
213 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Response</span></h4> | |
214 | </li> | |
215 | </ul> | |
216 | </li> | |
217 | </ul> | |
218 | </li> | |
219 | <li> | |
220 | <h5>opts: <a href="../interfaces/workeroptions.html" class="tsd-signature-type" data-tsd-kind="Interface">WorkerOptions</a><span class="tsd-signature-symbol"> = ...</span></h5> | |
221 | <div class="tsd-comment tsd-typography"> | |
222 | <p>Options for the worker.</p> | |
223 | </div> | |
224 | </li> | |
225 | </ul> | |
226 | <h4 class="tsd-returns-title">Returns <a href="threadworker.html" class="tsd-signature-type" data-tsd-kind="Class">ThreadWorker</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span></h4> | |
227 | </li> | |
228 | </ul> | |
229 | </section> | |
230 | </section> | |
231 | <section class="tsd-panel-group tsd-member-group "> | |
232 | <h2>Properties</h2> | |
233 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
234 | <a name="async" class="tsd-anchor"></a> | |
235 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> async</h3> | |
236 | <div class="tsd-signature tsd-kind-icon">async<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div> | |
237 | <aside class="tsd-sources"> | |
238 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#async">async</a></p> | |
239 | <ul> | |
849e0547 | 240 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L34">src/worker/abstract-worker.ts:34</a></li> |
5ea22628 JB |
241 | </ul> |
242 | </aside> | |
243 | <div class="tsd-comment tsd-typography"> | |
244 | <div class="lead"> | |
245 | <p>Whether the worker is working asynchronously or not.</p> | |
246 | </div> | |
247 | </div> | |
248 | </section> | |
249 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
250 | <a name="interval" class="tsd-anchor"></a> | |
251 | <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> interval</h3> | |
252 | <div class="tsd-signature tsd-kind-icon">interval<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Timeout</span></div> | |
253 | <aside class="tsd-sources"> | |
254 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#interval">interval</a></p> | |
255 | <ul> | |
849e0547 | 256 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L42">src/worker/abstract-worker.ts:42</a></li> |
5ea22628 JB |
257 | </ul> |
258 | </aside> | |
259 | <div class="tsd-comment tsd-typography"> | |
260 | <div class="lead"> | |
261 | <p>Handler ID of the <code>interval</code> alive check.</p> | |
262 | </div> | |
263 | </div> | |
264 | </section> | |
265 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
266 | <a name="killbehavior" class="tsd-anchor"></a> | |
267 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> kill<wbr>Behavior</h3> | |
268 | <div class="tsd-signature tsd-kind-icon">kill<wbr>Behavior<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"SOFT"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"HARD"</span></div> | |
269 | <aside class="tsd-sources"> | |
270 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#killbehavior">killBehavior</a></p> | |
271 | <ul> | |
849e0547 | 272 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L30">src/worker/abstract-worker.ts:30</a></li> |
5ea22628 JB |
273 | </ul> |
274 | </aside> | |
275 | <div class="tsd-comment tsd-typography"> | |
276 | <div class="lead"> | |
277 | <p>The kill behavior set as option on the Worker constructor or a default value.</p> | |
278 | </div> | |
279 | </div> | |
280 | </section> | |
281 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
282 | <a name="lasttask" class="tsd-anchor"></a> | |
283 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> last<wbr>Task</h3> | |
284 | <div class="tsd-signature tsd-kind-icon">last<wbr>Task<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> | |
285 | <aside class="tsd-sources"> | |
286 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#lasttask">lastTask</a></p> | |
287 | <ul> | |
849e0547 | 288 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L38">src/worker/abstract-worker.ts:38</a></li> |
5ea22628 JB |
289 | </ul> |
290 | </aside> | |
291 | <div class="tsd-comment tsd-typography"> | |
292 | <div class="lead"> | |
293 | <p>Timestamp of the last task processed by this worker.</p> | |
294 | </div> | |
295 | </div> | |
296 | </section> | |
297 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
298 | <a name="mainworker" class="tsd-anchor"></a> | |
299 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagOptional">Optional</span> main<wbr>Worker</h3> | |
300 | <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">MessagePort</span></div> | |
301 | <aside class="tsd-sources"> | |
302 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#mainworker">mainWorker</a></p> | |
303 | </aside> | |
304 | </section> | |
305 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
306 | <a name="maxinactivetime" class="tsd-anchor"></a> | |
307 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> max<wbr>Inactive<wbr>Time</h3> | |
308 | <div class="tsd-signature tsd-kind-icon">max<wbr>Inactive<wbr>Time<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> | |
309 | <aside class="tsd-sources"> | |
310 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#maxinactivetime">maxInactiveTime</a></p> | |
311 | <ul> | |
849e0547 | 312 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L26">src/worker/abstract-worker.ts:26</a></li> |
5ea22628 JB |
313 | </ul> |
314 | </aside> | |
315 | <div class="tsd-comment tsd-typography"> | |
316 | <div class="lead"> | |
317 | <p>The maximum time to keep this worker alive while idle. The pool automatically checks and terminates this worker when the time expires.</p> | |
318 | </div> | |
319 | </div> | |
320 | </section> | |
321 | <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> | |
322 | <a name="opts" class="tsd-anchor"></a> | |
323 | <h3><span class="tsd-flag ts-flagReadonly">Readonly</span> opts</h3> | |
324 | <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> | |
325 | <aside class="tsd-sources"> | |
326 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#opts">opts</a></p> | |
327 | </aside> | |
328 | </section> | |
329 | </section> | |
330 | <section class="tsd-panel-group tsd-member-group "> | |
331 | <h2>Methods</h2> | |
332 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
333 | <a name="asyncid" class="tsd-anchor"></a> | |
334 | <h3>async<wbr>Id</h3> | |
335 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
336 | <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> | |
337 | </ul> | |
338 | <ul class="tsd-descriptions"> | |
339 | <li class="tsd-description"> | |
340 | <aside class="tsd-sources"> | |
341 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#asyncid">asyncId</a></p> | |
342 | <ul> | |
343 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:159</li> | |
344 | </ul> | |
345 | </aside> | |
346 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> | |
347 | <p>the unique ID assigned to this AsyncResource instance.</p> | |
348 | </li> | |
349 | </ul> | |
350 | </section> | |
351 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
352 | <a name="bind" class="tsd-anchor"></a> | |
353 | <h3>bind</h3> | |
354 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
355 | <li class="tsd-signature tsd-kind-icon">bind<Func><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func</span><span class="tsd-signature-symbol"> & </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> | |
356 | </ul> | |
357 | <ul class="tsd-descriptions"> | |
358 | <li class="tsd-description"> | |
359 | <aside class="tsd-sources"> | |
360 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#bind">bind</a></p> | |
361 | <ul> | |
362 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:136</li> | |
363 | </ul> | |
364 | </aside> | |
365 | <div class="tsd-comment tsd-typography"> | |
366 | <div class="lead"> | |
367 | <p>Binds the given function to execute to this <code>AsyncResource</code>'s scope.</p> | |
368 | </div> | |
369 | </div> | |
370 | <h4 class="tsd-type-parameters-title">Type parameters</h4> | |
371 | <ul class="tsd-type-parameters"> | |
372 | <li> | |
373 | <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"> => </span><span class="tsd-signature-type">any</span></h4> | |
374 | </li> | |
375 | </ul> | |
376 | <h4 class="tsd-parameters-title">Parameters</h4> | |
377 | <ul class="tsd-parameters"> | |
378 | <li> | |
379 | <h5>fn: <span class="tsd-signature-type">Func</span></h5> | |
380 | <div class="tsd-comment tsd-typography"> | |
381 | <p>The function to bind to the current <code>AsyncResource</code>.</p> | |
382 | </div> | |
383 | </li> | |
384 | </ul> | |
385 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Func</span><span class="tsd-signature-symbol"> & </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> | |
386 | </li> | |
387 | </ul> | |
388 | </section> | |
389 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
390 | <a name="checkalive" class="tsd-anchor"></a> | |
391 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> check<wbr>Alive</h3> | |
392 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
393 | <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> | |
394 | </ul> | |
395 | <ul class="tsd-descriptions"> | |
396 | <li class="tsd-description"> | |
397 | <aside class="tsd-sources"> | |
398 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#checkalive">checkAlive</a></p> | |
399 | <ul> | |
849e0547 | 400 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L130">src/worker/abstract-worker.ts:130</a></li> |
5ea22628 JB |
401 | </ul> |
402 | </aside> | |
403 | <div class="tsd-comment tsd-typography"> | |
404 | <div class="lead"> | |
405 | <p>Check to see if the worker should be terminated, because its living too long.</p> | |
406 | </div> | |
407 | </div> | |
408 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> | |
409 | </li> | |
410 | </ul> | |
411 | </section> | |
412 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
413 | <a name="emitdestroy" class="tsd-anchor"></a> | |
414 | <h3>emit<wbr>Destroy</h3> | |
415 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
416 | <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><span class="tsd-signature-type">void</span></li> | |
417 | </ul> | |
418 | <ul class="tsd-descriptions"> | |
419 | <li class="tsd-description"> | |
420 | <aside class="tsd-sources"> | |
421 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#emitdestroy">emitDestroy</a></p> | |
422 | <ul> | |
423 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:154</li> | |
424 | </ul> | |
425 | </aside> | |
426 | <div class="tsd-comment tsd-typography"> | |
427 | <div class="lead"> | |
428 | <p>Call AsyncHooks destroy callbacks.</p> | |
429 | </div> | |
430 | </div> | |
431 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> | |
432 | </li> | |
433 | </ul> | |
434 | </section> | |
435 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
436 | <a name="getmainworker" class="tsd-anchor"></a> | |
437 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> get<wbr>Main<wbr>Worker</h3> | |
438 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
439 | <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">MessagePort</span></li> | |
440 | </ul> | |
441 | <ul class="tsd-descriptions"> | |
442 | <li class="tsd-description"> | |
443 | <aside class="tsd-sources"> | |
444 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#getmainworker">getMainWorker</a></p> | |
445 | <ul> | |
849e0547 | 446 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L113">src/worker/abstract-worker.ts:113</a></li> |
5ea22628 JB |
447 | </ul> |
448 | </aside> | |
449 | <div class="tsd-comment tsd-typography"> | |
450 | <div class="lead"> | |
451 | <p>Returns the main worker.</p> | |
452 | </div> | |
453 | </div> | |
454 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">MessagePort</span></h4> | |
455 | <p>Reference to the main worker.</p> | |
456 | </li> | |
457 | </ul> | |
458 | </section> | |
459 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
460 | <a name="handleerror" class="tsd-anchor"></a> | |
461 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> handle<wbr>Error</h3> | |
462 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
463 | <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> | |
464 | </ul> | |
465 | <ul class="tsd-descriptions"> | |
466 | <li class="tsd-description"> | |
467 | <aside class="tsd-sources"> | |
468 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#handleerror">handleError</a></p> | |
469 | <ul> | |
849e0547 | 470 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L142">src/worker/abstract-worker.ts:142</a></li> |
5ea22628 JB |
471 | </ul> |
472 | </aside> | |
473 | <div class="tsd-comment tsd-typography"> | |
474 | <div class="lead"> | |
475 | <p>Handle an error and convert it to a string so it can be sent back to the main worker.</p> | |
476 | </div> | |
477 | </div> | |
478 | <h4 class="tsd-parameters-title">Parameters</h4> | |
479 | <ul class="tsd-parameters"> | |
480 | <li> | |
481 | <h5>e: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Error</span></h5> | |
482 | <div class="tsd-comment tsd-typography"> | |
483 | <p>The error raised by the worker.</p> | |
484 | </div> | |
485 | </li> | |
486 | </ul> | |
487 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> | |
488 | <p>Message of the error.</p> | |
489 | </li> | |
490 | </ul> | |
491 | </section> | |
492 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
493 | <a name="run" class="tsd-anchor"></a> | |
494 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> run</h3> | |
495 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
496 | <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</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Response</span>, value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><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> | |
497 | </ul> | |
498 | <ul class="tsd-descriptions"> | |
499 | <li class="tsd-description"> | |
500 | <aside class="tsd-sources"> | |
501 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#run">run</a></p> | |
502 | <ul> | |
849e0547 | 503 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L152">src/worker/abstract-worker.ts:152</a></li> |
5ea22628 JB |
504 | </ul> |
505 | </aside> | |
506 | <div class="tsd-comment tsd-typography"> | |
507 | <div class="lead"> | |
508 | <p>Run the given function synchronously.</p> | |
509 | </div> | |
510 | </div> | |
511 | <h4 class="tsd-parameters-title">Parameters</h4> | |
512 | <ul class="tsd-parameters"> | |
513 | <li> | |
514 | <h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">Response</span></h5> | |
515 | <div class="tsd-comment tsd-typography"> | |
516 | <p>Function that will be executed.</p> | |
517 | </div> | |
518 | <ul class="tsd-parameters"> | |
519 | <li class="tsd-parameter-signature"> | |
520 | <ul class="tsd-signatures tsd-kind-type-literal"> | |
521 | <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</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Response</span></li> | |
522 | </ul> | |
523 | <ul class="tsd-descriptions"> | |
524 | <li class="tsd-description"> | |
525 | <h4 class="tsd-parameters-title">Parameters</h4> | |
526 | <ul class="tsd-parameters"> | |
527 | <li> | |
528 | <h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type">Data</span></h5> | |
529 | </li> | |
530 | </ul> | |
531 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Response</span></h4> | |
532 | </li> | |
533 | </ul> | |
534 | </li> | |
535 | </ul> | |
536 | </li> | |
537 | <li> | |
538 | <h5>value: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span></h5> | |
539 | <div class="tsd-comment tsd-typography"> | |
540 | <p>Input data for the given function.</p> | |
541 | </div> | |
542 | </li> | |
543 | </ul> | |
544 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> | |
545 | </li> | |
546 | </ul> | |
547 | </section> | |
548 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
549 | <a name="runasync" class="tsd-anchor"></a> | |
550 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> run<wbr>Async</h3> | |
551 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
552 | <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</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"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span>, value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><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> | |
553 | </ul> | |
554 | <ul class="tsd-descriptions"> | |
555 | <li class="tsd-description"> | |
556 | <aside class="tsd-sources"> | |
557 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#runasync">runAsync</a></p> | |
558 | <ul> | |
849e0547 | 559 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/abstract-worker.ts#L173">src/worker/abstract-worker.ts:173</a></li> |
5ea22628 JB |
560 | </ul> |
561 | </aside> | |
562 | <div class="tsd-comment tsd-typography"> | |
563 | <div class="lead"> | |
564 | <p>Run the given function asynchronously.</p> | |
565 | </div> | |
566 | </div> | |
567 | <h4 class="tsd-parameters-title">Parameters</h4> | |
568 | <ul class="tsd-parameters"> | |
569 | <li> | |
570 | <h5>fn: <span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">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"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span></h5> | |
571 | <div class="tsd-comment tsd-typography"> | |
572 | <p>Function that will be executed.</p> | |
573 | </div> | |
574 | <ul class="tsd-parameters"> | |
575 | <li class="tsd-parameter-signature"> | |
576 | <ul class="tsd-signatures tsd-kind-type-literal"> | |
577 | <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</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"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span></li> | |
578 | </ul> | |
579 | <ul class="tsd-descriptions"> | |
580 | <li class="tsd-description"> | |
581 | <h4 class="tsd-parameters-title">Parameters</h4> | |
582 | <ul class="tsd-parameters"> | |
583 | <li> | |
584 | <h5><span class="tsd-flag ts-flagOptional">Optional</span> data: <span class="tsd-signature-type">Data</span></h5> | |
585 | </li> | |
586 | </ul> | |
587 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">></span></h4> | |
588 | </li> | |
589 | </ul> | |
590 | </li> | |
591 | </ul> | |
592 | </li> | |
593 | <li> | |
594 | <h5>value: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Data</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span></h5> | |
595 | <div class="tsd-comment tsd-typography"> | |
596 | <p>Input data for the given function.</p> | |
597 | </div> | |
598 | </li> | |
599 | </ul> | |
600 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> | |
601 | </li> | |
602 | </ul> | |
603 | </section> | |
604 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
605 | <a name="runinasyncscope" class="tsd-anchor"></a> | |
606 | <h3>run<wbr>InAsync<wbr>Scope</h3> | |
607 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
608 | <li class="tsd-signature tsd-kind-icon">run<wbr>InAsync<wbr>Scope<This, Result><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"> => </span><span class="tsd-signature-type">Result</span>, thisArg<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">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">Result</span></li> | |
609 | </ul> | |
610 | <ul class="tsd-descriptions"> | |
611 | <li class="tsd-description"> | |
612 | <aside class="tsd-sources"> | |
613 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#runinasyncscope">runInAsyncScope</a></p> | |
614 | <ul> | |
615 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:149</li> | |
616 | </ul> | |
617 | </aside> | |
618 | <div class="tsd-comment tsd-typography"> | |
619 | <div class="lead"> | |
620 | <p>Call the provided function with the provided arguments in the | |
621 | execution context of the async resource. This will establish the | |
622 | context, trigger the AsyncHooks before callbacks, call the function, | |
623 | trigger the AsyncHooks after callbacks, and then restore the original | |
624 | execution context.</p> | |
625 | </div> | |
626 | </div> | |
627 | <h4 class="tsd-type-parameters-title">Type parameters</h4> | |
628 | <ul class="tsd-type-parameters"> | |
629 | <li> | |
630 | <h4>This</h4> | |
631 | </li> | |
632 | <li> | |
633 | <h4>Result</h4> | |
634 | </li> | |
635 | </ul> | |
636 | <h4 class="tsd-parameters-title">Parameters</h4> | |
637 | <ul class="tsd-parameters"> | |
638 | <li> | |
639 | <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"> => </span><span class="tsd-signature-type">Result</span></h5> | |
640 | <div class="tsd-comment tsd-typography"> | |
641 | <p>The function to call in the execution context of this | |
642 | async resource.</p> | |
643 | </div> | |
644 | <ul class="tsd-parameters"> | |
645 | <li class="tsd-parameter-signature"> | |
646 | <ul class="tsd-signatures tsd-kind-type-literal tsd-is-external"> | |
647 | <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">Result</span></li> | |
648 | </ul> | |
649 | <ul class="tsd-descriptions"> | |
650 | <li class="tsd-description"> | |
651 | <h4 class="tsd-parameters-title">Parameters</h4> | |
652 | <ul class="tsd-parameters"> | |
653 | <li> | |
654 | <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> | |
655 | </li> | |
656 | </ul> | |
657 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Result</span></h4> | |
658 | </li> | |
659 | </ul> | |
660 | </li> | |
661 | </ul> | |
662 | </li> | |
663 | <li> | |
664 | <h5><span class="tsd-flag ts-flagOptional">Optional</span> thisArg: <span class="tsd-signature-type">This</span></h5> | |
665 | <div class="tsd-comment tsd-typography"> | |
666 | <p>The receiver to be used for the function call.</p> | |
667 | </div> | |
668 | </li> | |
669 | <li> | |
670 | <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> | |
671 | <div class="tsd-comment tsd-typography"> | |
672 | <p>Optional arguments to pass to the function.</p> | |
673 | </div> | |
674 | </li> | |
675 | </ul> | |
676 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Result</span></h4> | |
677 | </li> | |
678 | </ul> | |
679 | </section> | |
680 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-protected"> | |
681 | <a name="sendtomainworker" class="tsd-anchor"></a> | |
682 | <h3><span class="tsd-flag ts-flagProtected">Protected</span> send<wbr>ToMain<wbr>Worker</h3> | |
683 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-protected"> | |
684 | <li class="tsd-signature tsd-kind-icon">send<wbr>ToMain<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"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><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> | |
685 | </ul> | |
686 | <ul class="tsd-descriptions"> | |
687 | <li class="tsd-description"> | |
688 | <aside class="tsd-sources"> | |
689 | <p>Overrides <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#sendtomainworker">sendToMainWorker</a></p> | |
690 | <ul> | |
849e0547 | 691 | <li>Defined in <a href="https://github.com/pioardi/poolifier/blob/36b71cf/src/worker/thread-worker.ts#L36">src/worker/thread-worker.ts:36</a></li> |
5ea22628 JB |
692 | </ul> |
693 | </aside> | |
694 | <h4 class="tsd-parameters-title">Parameters</h4> | |
695 | <ul class="tsd-parameters"> | |
696 | <li> | |
697 | <h5>message: <span class="tsd-signature-type">MessageValue</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Response</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span></h5> | |
698 | </li> | |
699 | </ul> | |
700 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> | |
701 | </li> | |
702 | </ul> | |
703 | </section> | |
704 | <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
705 | <a name="triggerasyncid" class="tsd-anchor"></a> | |
706 | <h3>trigger<wbr>Async<wbr>Id</h3> | |
707 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
708 | <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> | |
709 | </ul> | |
710 | <ul class="tsd-descriptions"> | |
711 | <li class="tsd-description"> | |
712 | <aside class="tsd-sources"> | |
713 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#triggerasyncid">triggerAsyncId</a></p> | |
714 | <ul> | |
715 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:164</li> | |
716 | </ul> | |
717 | </aside> | |
718 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> | |
719 | <p>the trigger ID for this AsyncResource instance.</p> | |
720 | </li> | |
721 | </ul> | |
722 | </section> | |
723 | <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"> | |
724 | <a name="bind-1" class="tsd-anchor"></a> | |
725 | <h3><span class="tsd-flag ts-flagStatic">Static</span> bind</h3> | |
726 | <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"> | |
727 | <li class="tsd-signature tsd-kind-icon">bind<Func><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func</span>, type<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func</span><span class="tsd-signature-symbol"> & </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> | |
728 | </ul> | |
729 | <ul class="tsd-descriptions"> | |
730 | <li class="tsd-description"> | |
731 | <aside class="tsd-sources"> | |
732 | <p>Inherited from <a href="abstractworker.html">AbstractWorker</a>.<a href="abstractworker.html#bind-1">bind</a></p> | |
733 | <ul> | |
734 | <li>Defined in node_modules/@types/node/async_hooks.d.ts:130</li> | |
735 | </ul> | |
736 | </aside> | |
737 | <div class="tsd-comment tsd-typography"> | |
738 | <div class="lead"> | |
739 | <p>Binds the given function to the current execution context.</p> | |
740 | </div> | |
741 | </div> | |
742 | <h4 class="tsd-type-parameters-title">Type parameters</h4> | |
743 | <ul class="tsd-type-parameters"> | |
744 | <li> | |
745 | <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"> => </span><span class="tsd-signature-type">any</span></h4> | |
746 | </li> | |
747 | </ul> | |
748 | <h4 class="tsd-parameters-title">Parameters</h4> | |
749 | <ul class="tsd-parameters"> | |
750 | <li> | |
751 | <h5>fn: <span class="tsd-signature-type">Func</span></h5> | |
752 | <div class="tsd-comment tsd-typography"> | |
753 | <p>The function to bind to the current execution context.</p> | |
754 | </div> | |
755 | </li> | |
756 | <li> | |
757 | <h5><span class="tsd-flag ts-flagOptional">Optional</span> type: <span class="tsd-signature-type">string</span></h5> | |
758 | <div class="tsd-comment tsd-typography"> | |
759 | <p>An optional name to associate with the underlying <code>AsyncResource</code>.</p> | |
760 | </div> | |
761 | </li> | |
762 | </ul> | |
763 | <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Func</span><span class="tsd-signature-symbol"> & </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> | |
764 | </li> | |
765 | </ul> | |
766 | </section> | |
767 | </section> | |
768 | </div> | |
769 | <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> | |
770 | <nav class="tsd-navigation primary"> | |
771 | <ul> | |
772 | <li class=" "> | |
773 | <a href="../index.html">Exports</a> | |
774 | </li> | |
775 | </ul> | |
776 | </nav> | |
777 | <nav class="tsd-navigation secondary menu-sticky"> | |
778 | <ul class="before-current"> | |
779 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
780 | <a href="abstractworker.html" class="tsd-kind-icon">Abstract<wbr>Worker</a> | |
781 | </li> | |
782 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
783 | <a href="clusterworker.html" class="tsd-kind-icon">Cluster<wbr>Worker</a> | |
784 | </li> | |
785 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
786 | <a href="dynamicclusterpool.html" class="tsd-kind-icon">Dynamic<wbr>Cluster<wbr>Pool</a> | |
787 | </li> | |
788 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
789 | <a href="dynamicthreadpool.html" class="tsd-kind-icon">Dynamic<wbr>Thread<wbr>Pool</a> | |
790 | </li> | |
791 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
792 | <a href="fixedclusterpool.html" class="tsd-kind-icon">Fixed<wbr>Cluster<wbr>Pool</a> | |
793 | </li> | |
794 | <li class=" tsd-kind-class tsd-has-type-parameter"> | |
795 | <a href="fixedthreadpool.html" class="tsd-kind-icon">Fixed<wbr>Thread<wbr>Pool</a> | |
796 | </li> | |
797 | </ul> | |
798 | <ul class="current"> | |
799 | <li class="current tsd-kind-class tsd-has-type-parameter"> | |
800 | <a href="threadworker.html" class="tsd-kind-icon">Thread<wbr>Worker</a> | |
801 | <ul> | |
802 | <li class=" tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited"> | |
803 | <a href="threadworker.html#constructor" class="tsd-kind-icon">constructor</a> | |
804 | </li> | |
805 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
806 | <a href="threadworker.html#async" class="tsd-kind-icon">async</a> | |
807 | </li> | |
808 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
809 | <a href="threadworker.html#interval" class="tsd-kind-icon">interval</a> | |
810 | </li> | |
811 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
812 | <a href="threadworker.html#killbehavior" class="tsd-kind-icon">kill<wbr>Behavior</a> | |
813 | </li> | |
814 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
815 | <a href="threadworker.html#lasttask" class="tsd-kind-icon">last<wbr>Task</a> | |
816 | </li> | |
817 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
818 | <a href="threadworker.html#mainworker" class="tsd-kind-icon">main<wbr>Worker</a> | |
819 | </li> | |
820 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
821 | <a href="threadworker.html#maxinactivetime" class="tsd-kind-icon">max<wbr>Inactive<wbr>Time</a> | |
822 | </li> | |
823 | <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> | |
824 | <a href="threadworker.html#opts" class="tsd-kind-icon">opts</a> | |
825 | </li> | |
826 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
827 | <a href="threadworker.html#asyncid" class="tsd-kind-icon">async<wbr>Id</a> | |
828 | </li> | |
829 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
830 | <a href="threadworker.html#bind" class="tsd-kind-icon">bind</a> | |
831 | </li> | |
832 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
833 | <a href="threadworker.html#checkalive" class="tsd-kind-icon">check<wbr>Alive</a> | |
834 | </li> | |
835 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
836 | <a href="threadworker.html#emitdestroy" class="tsd-kind-icon">emit<wbr>Destroy</a> | |
837 | </li> | |
838 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
839 | <a href="threadworker.html#getmainworker" class="tsd-kind-icon">get<wbr>Main<wbr>Worker</a> | |
840 | </li> | |
841 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
842 | <a href="threadworker.html#handleerror" class="tsd-kind-icon">handle<wbr>Error</a> | |
843 | </li> | |
844 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
845 | <a href="threadworker.html#run" class="tsd-kind-icon">run</a> | |
846 | </li> | |
847 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-protected"> | |
848 | <a href="threadworker.html#runasync" class="tsd-kind-icon">run<wbr>Async</a> | |
849 | </li> | |
850 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"> | |
851 | <a href="threadworker.html#runinasyncscope" class="tsd-kind-icon">run<wbr>InAsync<wbr>Scope</a> | |
852 | </li> | |
853 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-protected"> | |
854 | <a href="threadworker.html#sendtomainworker" class="tsd-kind-icon">send<wbr>ToMain<wbr>Worker</a> | |
855 | </li> | |
856 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-external"> | |
857 | <a href="threadworker.html#triggerasyncid" class="tsd-kind-icon">trigger<wbr>Async<wbr>Id</a> | |
858 | </li> | |
859 | <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-static tsd-is-external"> | |
860 | <a href="threadworker.html#bind-1" class="tsd-kind-icon">bind</a> | |
861 | </li> | |
862 | </ul> | |
863 | </li> | |
864 | </ul> | |
865 | <ul class="after-current"> | |
866 | <li class=" tsd-kind-interface"> | |
867 | <a href="../interfaces/clusterpooloptions.html" class="tsd-kind-icon">Cluster<wbr>Pool<wbr>Options</a> | |
868 | </li> | |
869 | <li class=" tsd-kind-interface tsd-has-type-parameter"> | |
870 | <a href="../interfaces/ipool.html" class="tsd-kind-icon">IPool</a> | |
871 | </li> | |
872 | <li class=" tsd-kind-interface"> | |
873 | <a href="../interfaces/iworker.html" class="tsd-kind-icon">IWorker</a> | |
874 | </li> | |
875 | <li class=" tsd-kind-interface tsd-has-type-parameter"> | |
876 | <a href="../interfaces/pooloptions.html" class="tsd-kind-icon">Pool<wbr>Options</a> | |
877 | </li> | |
878 | <li class=" tsd-kind-interface"> | |
879 | <a href="../interfaces/workeroptions.html" class="tsd-kind-icon">Worker<wbr>Options</a> | |
880 | </li> | |
881 | <li class=" tsd-kind-type-alias tsd-has-type-parameter"> | |
882 | <a href="../index.html#errorhandler" class="tsd-kind-icon">Error<wbr>Handler</a> | |
883 | </li> | |
884 | <li class=" tsd-kind-type-alias tsd-has-type-parameter"> | |
885 | <a href="../index.html#exithandler" class="tsd-kind-icon">Exit<wbr>Handler</a> | |
886 | </li> | |
887 | <li class=" tsd-kind-type-alias"> | |
888 | <a href="../index.html#killbehavior" class="tsd-kind-icon">Kill<wbr>Behavior</a> | |
889 | </li> | |
890 | <li class=" tsd-kind-type-alias tsd-has-type-parameter"> | |
891 | <a href="../index.html#onlinehandler" class="tsd-kind-icon">Online<wbr>Handler</a> | |
892 | </li> | |
893 | <li class=" tsd-kind-type-alias"> | |
894 | <a href="../index.html#threadworkerwithmessagechannel" class="tsd-kind-icon">Thread<wbr>Worker<wbr>With<wbr>Message<wbr>Channel</a> | |
895 | </li> | |
896 | <li class=" tsd-kind-type-alias"> | |
897 | <a href="../index.html#workerchoicestrategy" class="tsd-kind-icon">Worker<wbr>Choice<wbr>Strategy</a> | |
898 | </li> | |
899 | <li class=" tsd-kind-variable"> | |
900 | <a href="../index.html#killbehaviors" class="tsd-kind-icon">Kill<wbr>Behaviors</a> | |
901 | </li> | |
902 | <li class=" tsd-kind-variable"> | |
903 | <a href="../index.html#workerchoicestrategies" class="tsd-kind-icon">Worker<wbr>Choice<wbr>Strategies</a> | |
904 | </li> | |
905 | </ul> | |
906 | </nav> | |
907 | </div> | |
908 | </div> | |
909 | </div> | |
910 | <footer class="with-border-bottom"> | |
911 | <div class="container"> | |
912 | <h2>Legend</h2> | |
913 | <div class="tsd-legend-group"> | |
914 | <ul class="tsd-legend"> | |
915 | <li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li> | |
916 | <li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li> | |
917 | </ul> | |
918 | <ul class="tsd-legend"> | |
919 | <li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li> | |
920 | <li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li> | |
921 | </ul> | |
922 | <ul class="tsd-legend"> | |
923 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li> | |
924 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li> | |
925 | </ul> | |
926 | <ul class="tsd-legend"> | |
927 | <li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li> | |
928 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li> | |
929 | </ul> | |
930 | <ul class="tsd-legend"> | |
931 | <li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li> | |
932 | </ul> | |
933 | </div> | |
934 | </div> | |
935 | </footer> | |
936 | <div class="container tsd-generator"> | |
937 | <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p> | |
938 | </div> | |
939 | <div class="overlay"></div> | |
940 | <script src="../assets/js/main.js"></script> | |
941 | </body> | |
942 | </html> |