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.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/bun.js/bindings/ScriptExecutionContext.cpp') diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index 0293ecc35..b7b7ef16d 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -110,6 +110,16 @@ us_socket_context_t* ScriptExecutionContext::connectedWebSocketKindClientSSL() return registerWebSocketClientContext(this, webSocketContextSSL()); } +ScriptExecutionContextIdentifier ScriptExecutionContext::generateIdentifier() +{ + Locker locker { allScriptExecutionContextsMapLock }; + + // ASSERT(allScriptExecutionContextsMap().contains(m_identifier)); + // allScriptExecutionContextsMap().remove(m_identifier); + + return ++lastUniqueIdentifier; +} + void ScriptExecutionContext::regenerateIdentifier() { Locker locker { allScriptExecutionContextsMapLock }; -- cgit v1.2.3