summaryrefslogtreecommitdiff
path: root/ext/net/01_net.js
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-11-01 20:26:12 +0100
committerGitHub <noreply@github.com>2023-11-01 20:26:12 +0100
commitd42f1543121e7245789a96a485d1ef7645cb5fba (patch)
treed57a10ac527fe5b6796a3a8866af95f0f1a5d7bd /ext/net/01_net.js
parent1d19b1011bd7df50598f5981408c2d78c35b76d2 (diff)
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>
Diffstat (limited to 'ext/net/01_net.js')
-rw-r--r--ext/net/01_net.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/net/01_net.js b/ext/net/01_net.js
index f2bf5e7df..05aca07e5 100644
--- a/ext/net/01_net.js
+++ b/ext/net/01_net.js
@@ -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;
}