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
|
@ -70,11 +70,24 @@ import {
|
|||
windowOrWorkerGlobalScope,
|
||||
workerRuntimeGlobalProperties,
|
||||
} from "ext:runtime/98_global_scope.js";
|
||||
import { SymbolAsyncDispose, SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||
|
||||
// deno-lint-ignore prefer-primordials
|
||||
Symbol.dispose ??= Symbol("Symbol.dispose");
|
||||
// deno-lint-ignore prefer-primordials
|
||||
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
||||
if (Symbol.dispose) throw "V8 supports Symbol.dispose now, no need to shim it!";
|
||||
ObjectDefineProperties(Symbol, {
|
||||
dispose: {
|
||||
value: SymbolDispose,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
},
|
||||
asyncDispose: {
|
||||
value: SymbolAsyncDispose,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
},
|
||||
});
|
||||
|
||||
let windowIsClosing = false;
|
||||
let globalThis_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue