+20
-0
lines changedFilter options
+20
-0
lines changed Original file line number Diff line number Diff line change
@@ -1861,6 +1861,21 @@ Calling `unref()` on a worker allows the thread to exit if this is the only
1861
1861
active handle in the event system. If the worker is already `unref()`ed calling
1862
1862
`unref()` again has no effect.
1863
1863
1864
+
### `worker[Symbol.asyncDispose]()`
1865
+
1866
+
<!-- YAML
1867
+
added: REPLACEME
1868
+
-->
1869
+
1870
+
Calls [`worker.terminate()`][] when the dispose scope is exited.
1871
+
1872
+
```js
1873
+
async function example() {
1874
+
await using worker = new Worker('for (;;) {}', { eval: true });
1875
+
// Worker is automatically terminate when the scope is exited.
1876
+
}
1877
+
```
1878
+
1864
1879
## Notes
1865
1880
1866
1881
### Synchronous blocking of stdio
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ const {
19
19
String,
20
20
StringPrototypeTrim,
21
21
Symbol,
22
+
SymbolAsyncDispose,
22
23
SymbolFor,
23
24
TypedArrayPrototypeFill,
24
25
Uint32Array,
@@ -407,6 +408,10 @@ class Worker extends EventEmitter {
407
408
});
408
409
}
409
410
411
+
async [SymbolAsyncDispose]() {
412
+
await this.terminate();
413
+
}
414
+
410
415
ref() {
411
416
if (this[kHandle] === null) return;
412
417
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4