mirror of
https://github.com/denoland/deno.git
synced 2025-08-31 07:47:46 +00:00
feat: disposable Deno resources (#20845)
This commit implements Symbol.dispose and Symbol.asyncDispose for the relevant resources. Closes #20839 --------- Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
1d19b1011b
commit
d42f154312
21 changed files with 342 additions and 35 deletions
|
@ -9,6 +9,8 @@ import {
|
|||
writableStreamForRid,
|
||||
} from "ext:deno_web/06_streams.js";
|
||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||
|
||||
const primordials = globalThis.__bootstrap.primordials;
|
||||
const {
|
||||
ArrayPrototypeFilter,
|
||||
|
@ -160,6 +162,10 @@ class Conn {
|
|||
(id) => core.unrefOp(id),
|
||||
);
|
||||
}
|
||||
|
||||
[SymbolDispose]() {
|
||||
core.tryClose(this.#rid);
|
||||
}
|
||||
}
|
||||
|
||||
class TcpConn extends Conn {
|
||||
|
@ -249,6 +255,10 @@ class Listener {
|
|||
core.close(this.rid);
|
||||
}
|
||||
|
||||
[SymbolDispose]() {
|
||||
core.tryClose(this.#rid);
|
||||
}
|
||||
|
||||
[SymbolAsyncIterator]() {
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue