From 209dc981c0ef52de5c80eab5d24ec8a8eba765e8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 16 Jul 2023 21:15:24 -0700 Subject: Implement Workers (#3645) * copy files * format * options * Introduce `Worker`, `onmessage`, `onerror`, and `postMessage` globals * Stub `Worker.prototype.ref` & `Worker.prototype.unref` * Update web_worker.zig * Worker works * Add "mini" mode * add wakeup * Partially fix the keep-alive issue * clean up refer behavior * Implement `serialize` & `deserialize` in `bun:jsc` & add polyfill for `node:v8` * Types & docs * Update globals.d.ts * Add mutex * Fixes --------- Co-authored-by: Dylan Conway Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/ScriptExecutionContext.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/bun.js/bindings/ScriptExecutionContext.h') diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index fcf65f477..c3fbd7c9b 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -81,6 +81,15 @@ public: regenerateIdentifier(); } + ScriptExecutionContext(JSC::VM* vm, JSC::JSGlobalObject* globalObject, ScriptExecutionContextIdentifier identifier) + : m_vm(vm) + , m_globalObject(globalObject) + , m_identifier(identifier) + { + } + + static ScriptExecutionContextIdentifier generateIdentifier(); + JSC::JSGlobalObject* jsGlobalObject() { return m_globalObject; @@ -170,6 +179,12 @@ public: JSC::VM& vm() { return *m_vm; } ScriptExecutionContextIdentifier identifier() const { return m_identifier; } + bool isWorker = false; + void setGlobalObject(JSC::JSGlobalObject* globalObject) + { + m_globalObject = globalObject; + } + private: JSC::VM* m_vm = nullptr; JSC::JSGlobalObject* m_globalObject = nullptr; -- cgit v1.2.3