summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorsnek <snek@deno.com>2024-08-02 11:16:59 -0700
committerGitHub <noreply@github.com>2024-08-02 18:16:59 +0000
commit71ca61e189cca9215982ce4598b7a4da8430c584 (patch)
treea0dd2aa94cf61103b1dbcfa28a6c67feebf6eedd /runtime/js
parent3a1a1cc030fb7fc90d51ee27162466d6ac924926 (diff)
Revert "feat: async context" (#24856)
Reverts denoland/deno#24402 deno_web can't depend on code in runtime
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/01_async_context.js45
1 files changed, 0 insertions, 45 deletions
diff --git a/runtime/js/01_async_context.js b/runtime/js/01_async_context.js
deleted file mode 100644
index 9c0236fbe..000000000
--- a/runtime/js/01_async_context.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-
-import { primordials } from "ext:core/mod.js";
-import { op_get_extras_binding_object } from "ext:core/ops";
-
-const {
- SafeWeakMap,
-} = primordials;
-
-const {
- getContinuationPreservedEmbedderData,
- setContinuationPreservedEmbedderData,
-} = op_get_extras_binding_object();
-
-let counter = 0;
-
-export const getAsyncContext = getContinuationPreservedEmbedderData;
-export const setAsyncContext = setContinuationPreservedEmbedderData;
-
-export class AsyncVariable {
- #id = counter++;
- #data = new SafeWeakMap();
-
- enter(value) {
- const previousContextMapping = getAsyncContext();
- const entry = { id: this.#id };
- const asyncContextMapping = {
- __proto__: null,
- ...previousContextMapping,
- [this.#id]: entry,
- };
- this.#data.set(entry, value);
- setAsyncContext(asyncContextMapping);
- return previousContextMapping;
- }
-
- get() {
- const current = getAsyncContext();
- const entry = current?.[this.#id];
- if (entry) {
- return this.#data.get(entry);
- }
- return undefined;
- }
-}