-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkerManager.html
303 lines (297 loc) · 39.8 KB
/
WorkerManager.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>WorkerManager | @matrixai/workers</title><meta name="description" content="Documentation for @matrixai/workers"/><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 defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
<div class="tsd-toolbar-contents container">
<div class="table-cell" id="tsd-search" data-base="..">
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
<div class="field">
<div id="tsd-toolbar-links"></div></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">@matrixai/workers</a></div>
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
<div class="container container-main">
<div class="col-content">
<div class="tsd-page-title">
<ul class="tsd-breadcrumb">
<li><a href="../modules.html">@matrixai/workers</a></li>
<li><a href="WorkerManager.html">WorkerManager</a></li></ul>
<h1>Class WorkerManager<Manifest></h1></div>
<section class="tsd-panel">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameter-list">
<li>
<h4><span class="tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol"> extends </span><a href="../types/WorkerManifest.html" class="tsd-signature-type tsd-kind-type-alias">WorkerManifest</a></h4></li></ul></section>
<section class="tsd-panel tsd-hierarchy">
<h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">WorkerManager</span></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L10">src/WorkerManager.ts:10</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
<h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex=0><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></svg> Index</h5></summary>
<div class="tsd-accordion-details">
<section class="tsd-index-section">
<h3 class="tsd-index-heading">Constructors</h3>
<div class="tsd-index-list"><a href="WorkerManager.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-512"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g></svg><span>constructor</span></a>
</div></section>
<section class="tsd-index-section">
<h3 class="tsd-index-heading">Properties</h3>
<div class="tsd-index-list"><a href="WorkerManager.html#logger" class="tsd-index-link tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-1024"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g></svg><span>logger</span></a>
<a href="WorkerManager.html#methods" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>methods</span></a>
<a href="WorkerManager.html#pool" class="tsd-index-link tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>pool</span></a>
</div></section>
<section class="tsd-index-section">
<h3 class="tsd-index-heading">Methods</h3>
<div class="tsd-index-list"><a href="WorkerManager.html#call" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-2048"><rect fill="var(--color-icon-background)" stroke="#FF4DB8" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g></svg><span>call</span></a>
<a href="WorkerManager.html#completed" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>completed</span></a>
<a href="WorkerManager.html#destroy" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>destroy</span></a>
<a href="WorkerManager.html#queue" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>queue</span></a>
<a href="WorkerManager.html#settled" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>settled</span></a>
<a href="WorkerManager.html#createWorkerManager" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>create<wbr/>Worker<wbr/>Manager</span></a>
</div></section></div></details></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" id="icon-anchor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="constructor.new_WorkerManager"><span class="tsd-kind-constructor-signature">new <wbr/>Worker<wbr/>Manager</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">config</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WorkerManager.html" class="tsd-signature-type tsd-kind-class">WorkerManager</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span><a href="#constructor.new_WorkerManager" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Constructs a new instance of the class using the provided parameters.</p>
</div>
<section class="tsd-panel">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameter-list">
<li>
<h4><span class="tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol"> extends </span><a href="../types/WorkerManifest.html" class="tsd-signature-type tsd-kind-type-alias">WorkerManifest</a></h4></li></ul></section>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<h5><span class="tsd-kind-parameter">config</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">cores</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">logger</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type ">Logger</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">manifest</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">workerFactory</span><span class="tsd-signature-symbol">: </span><a href="../types/WorkerFactory.html" class="tsd-signature-type tsd-kind-type-alias">WorkerFactory</a><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></h5>
<div class="tsd-comment tsd-typography"><p>The configuration for the constructor.</p>
</div>
<div class="tsd-comment tsd-typography"></div>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">cores</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5>
<div class="tsd-comment tsd-typography"><p>The number of cores to allocate for the worker pool.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">logger</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type ">Logger</span></h5>
<div class="tsd-comment tsd-typography"><p>The logger instance for logging messages.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">manifest</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span></h5>
<div class="tsd-comment tsd-typography"><p>The manifest containing method definitions.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">worker<wbr/>Factory</span><span class="tsd-signature-symbol">: </span><a href="../types/WorkerFactory.html" class="tsd-signature-type tsd-kind-type-alias">WorkerFactory</a></h5>
<div class="tsd-comment tsd-typography"><p>The factory for creating worker instances.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="WorkerManager.html" class="tsd-signature-type tsd-kind-class">WorkerManager</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L60">src/WorkerManager.ts:60</a></li></ul></aside></li></ul></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-is-protected"><a id="logger" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagProtected">Protected</code> <span>logger</span><a href="#logger" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">logger</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">Logger</span></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L44">src/WorkerManager.ts:44</a></li></ul></aside></section>
<section class="tsd-panel tsd-member"><a id="methods" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>methods</span><a href="#methods" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">methods</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span></div>
<div class="tsd-comment tsd-typography"><p>Methods exposes a fully typed interface for making calls using workers.
It provides all the available methods provided by the manifest with proper types applied.</p>
</div>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L49">src/WorkerManager.ts:49</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-protected"><a id="pool" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagProtected">Protected</code> <span>pool</span><a href="#pool" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">pool</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">WorkerPool</span></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L43">src/WorkerManager.ts:43</a></li></ul></aside></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Methods</h2>
<section class="tsd-panel tsd-member"><a id="call" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>call</span><a href="#call" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="call.call-1"><span class="tsd-kind-call-signature">call</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">task</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><a href="../types/WorkerResult.html" class="tsd-signature-type tsd-kind-type-alias">WorkerResult</a><span class="tsd-signature-symbol">></span><a href="#call.call-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Processes a worker task by enqueuing it for execution.</p>
</div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<h5><span class="tsd-kind-parameter">task</span>: <a href="../types/WorkerTaskInformation.html" class="tsd-signature-type tsd-kind-type-alias">WorkerTaskInformation</a></h5>
<div class="tsd-comment tsd-typography"><p>The information about the worker task to be executed.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><a href="../types/WorkerResult.html" class="tsd-signature-type tsd-kind-type-alias">WorkerResult</a><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves with the result of the worker task execution.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L109">src/WorkerManager.ts:109</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="completed" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>completed</span><a href="#completed" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="completed.completed-1"><span class="tsd-kind-call-signature">completed</span><span class="tsd-signature-symbol">(</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">void</span><span class="tsd-signature-symbol">></span><a href="#completed.completed-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Returns a promise that resolves when the pool status becomes 'idle',
or rejects if the pool status changes to 'terminated' or an error occurs.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves when the pool is idle or rejects with an error.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L136">src/WorkerManager.ts:136</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="destroy" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>destroy</span><a href="#destroy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="destroy.destroy-1"><span class="tsd-kind-call-signature">destroy</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">params</span><span class="tsd-signature-symbol">?</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">void</span><span class="tsd-signature-symbol">></span><a href="#destroy.destroy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Destroys the WorkerManager instance and terminates its associated pool.</p>
</div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-parameter">params</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">force</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></h5>
<div class="tsd-comment tsd-typography"><p>An optional configuration object.</p>
</div>
<div class="tsd-comment tsd-typography"></div>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-property">force</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5>
<div class="tsd-comment tsd-typography"><p>Indicates whether to forcefully terminate the pool.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves when the destruction process is complete.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L95">src/WorkerManager.ts:95</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="queue" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>queue</span><a href="#queue" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="queue.queue-1"><span class="tsd-kind-call-signature">queue</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">task</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><a href="../types/WorkerResult.html" class="tsd-signature-type tsd-kind-type-alias">WorkerResult</a><span class="tsd-signature-symbol">></span><a href="#queue.queue-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Enqueues a task to be processed by the worker pool.</p>
</div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<h5><span class="tsd-kind-parameter">task</span>: <a href="../types/WorkerTaskInformation.html" class="tsd-signature-type tsd-kind-type-alias">WorkerTaskInformation</a></h5>
<div class="tsd-comment tsd-typography"><p>The task to be processed by the worker pool.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><a href="../types/WorkerResult.html" class="tsd-signature-type tsd-kind-type-alias">WorkerResult</a><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves with the result of the task or rejects with an error if the task fails or cannot be processed.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L120">src/WorkerManager.ts:120</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="settled" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>settled</span><a href="#settled" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="settled.settled-1"><span class="tsd-kind-call-signature">settled</span><span class="tsd-signature-symbol">(</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">void</span><span class="tsd-signature-symbol">></span><a href="#settled.settled-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Returns a promise that resolves when the pool status becomes 'idle',
or rejects if the pool status becomes 'terminated'.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves once the pool status is 'idle',
or rejects if the pool status becomes 'terminated'.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L148">src/WorkerManager.ts:148</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="createWorkerManager" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>create<wbr/>Worker<wbr/>Manager</span><a href="#createWorkerManager" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures">
<li class="tsd-signature tsd-anchor-link" id="createWorkerManager.createWorkerManager-1"><span class="tsd-kind-call-signature">create<wbr/>Worker<wbr/>Manager</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</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><a href="WorkerManager.html" class="tsd-signature-type tsd-kind-class">WorkerManager</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#createWorkerManager.createWorkerManager-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li>
<li class="tsd-description">
<div class="tsd-comment tsd-typography"><p>Creates and initializes a new instance of WorkerManager.</p>
</div>
<section class="tsd-panel">
<h4>Type Parameters</h4>
<ul class="tsd-type-parameter-list">
<li>
<h4><span class="tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol"> extends </span><a href="../types/WorkerManifest.html" class="tsd-signature-type tsd-kind-type-alias">WorkerManifest</a></h4></li></ul></section>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<h5><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">cores</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">logger</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type ">Logger</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">manifest</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-kind-property">workerFactory</span><span class="tsd-signature-symbol">: </span><a href="../types/WorkerFactory.html" class="tsd-signature-type tsd-kind-type-alias">WorkerFactory</a><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></h5>
<div class="tsd-comment tsd-typography"><p>The configuration options for the WorkerManager.</p>
</div>
<div class="tsd-comment tsd-typography"></div>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-property">cores</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5>
<div class="tsd-comment tsd-typography"><p>The number of cores to allocate for workers. Defaults to 1.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li>
<li class="tsd-parameter">
<h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-property">logger</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type ">Logger</span></h5></li>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">manifest</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span></h5>
<div class="tsd-comment tsd-typography"><p>The manifest defining the worker capabilities and operations.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">worker<wbr/>Factory</span><span class="tsd-signature-symbol">: </span><a href="../types/WorkerFactory.html" class="tsd-signature-type tsd-kind-type-alias">WorkerFactory</a></h5>
<div class="tsd-comment tsd-typography"><p>The factory for creating workers.</p>
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Promise</span><span class="tsd-signature-symbol"><</span><a href="WorkerManager.html" class="tsd-signature-type tsd-kind-class">WorkerManager</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Manifest</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A promise that resolves to a new WorkerManager instance.</p>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-workers/blob/master/src/WorkerManager.ts#L21">src/WorkerManager.ts:21</a></li></ul></aside></li></ul></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)" id="icon-chevronDown"></path></svg>Settings</h3></summary>
<div class="tsd-accordion-details">
<div class="tsd-filter-visibility">
<h4 class="uppercase">Member Visibility</h4><form>
<ul id="tsd-filter-options">
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
<div class="tsd-theme-toggle">
<h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
<details open class="tsd-index-accordion tsd-page-navigation"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>On This Page</h3></summary>
<div class="tsd-accordion-details">
<ul>
<li><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-512"></use></svg><span>constructor</span></a></li>
<li><a href="#logger" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>logger</span></a></li>
<li><a href="#methods" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>methods</span></a></li>
<li><a href="#pool" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>pool</span></a></li>
<li><a href="#call" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>call</span></a></li>
<li><a href="#completed" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>completed</span></a></li>
<li><a href="#destroy" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>destroy</span></a></li>
<li><a href="#queue" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>queue</span></a></li>
<li><a href="#settled" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>settled</span></a></li>
<li><a href="#createWorkerManager" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2048"></use></svg><span>create<wbr/>Worker<wbr/>Manager</span></a></li></ul></div></details></div>
<div class="site-menu">
<nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@matrixai/workers</span></a>
<ul class="tsd-small-nested-navigation">
<li><a href="../modules/errors.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4"></use></svg><span>errors</span></a></li>
<li><a href="WorkerManager.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-128"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g></svg><span>Worker<wbr/>Manager</span></a></li>
<li><a href="../types/TaskCallback.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4194304"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g></svg><span>Task<wbr/>Callback</span></a></li>
<li><a href="../types/WorkerFactory.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Factory</span></a></li>
<li><a href="../types/WorkerFunction.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Function</span></a></li>
<li><a href="../types/WorkerManifest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Manifest</span></a></li>
<li><a href="../types/WorkerResult.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Result</span></a></li>
<li><a href="../types/WorkerResultInternal.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Result<wbr/>Internal</span></a></li>
<li><a href="../types/WorkerTaskInformation.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Worker<wbr/>Task<wbr/>Information</span></a></li>
<li><a href="../functions/expose.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g></svg><span>expose</span></a></li></ul></nav></div></div></div>
<div class="tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
<div class="overlay"></div></body></html>