From 76f2168393d5b97aadce573415143383ccd3d78e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 18 Apr 2019 00:56:57 +0200 Subject: worker: add ability to unshift message from MessagePort In combination with Atomics, this makes it possible to implement generic synchronous functionality, e.g. `importScript()`, in Workers purely by communicating with other threads. This is a continuation of https://github.com/nodejs/node/pull/26686, where a preference for a solution was voiced that allowed reading individual messages, rather than emitting all messages through events. PR-URL: https://github.com/nodejs/node/pull/27294 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Ruben Bridgewater --- src/node_messaging.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/node_messaging.h') diff --git a/src/node_messaging.h b/src/node_messaging.h index 08a6798e3c..9f7929aa1c 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -163,6 +163,7 @@ class MessagePort : public HandleWrap { static void Start(const v8::FunctionCallbackInfo& args); static void Stop(const v8::FunctionCallbackInfo& args); static void Drain(const v8::FunctionCallbackInfo& args); + static void ReceiveMessage(const v8::FunctionCallbackInfo& args); /* static */ static void MoveToContext(const v8::FunctionCallbackInfo& args); @@ -200,6 +201,8 @@ class MessagePort : public HandleWrap { void OnClose() override; void OnMessage(); void TriggerAsync(); + v8::MaybeLocal ReceiveMessage(v8::Local context, + bool only_if_receiving); std::unique_ptr data_ = nullptr; bool receiving_messages_ = false; -- cgit v1.2.3