summaryrefslogtreecommitdiff
path: root/src/node_messaging.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-04-18 00:56:57 +0200
committerAnna Henningsen <anna@addaleax.net>2019-05-19 22:01:34 +0200
commit76f2168393d5b97aadce573415143383ccd3d78e (patch)
treedc1f2de83234e4fb1892e82d6d432f8ed54d2a98 /src/node_messaging.h
parent13d2df530b613f5f41db3e9680fa85d55bea0f1e (diff)
downloadandroid-node-v8-76f2168393d5b97aadce573415143383ccd3d78e.tar.gz
android-node-v8-76f2168393d5b97aadce573415143383ccd3d78e.tar.bz2
android-node-v8-76f2168393d5b97aadce573415143383ccd3d78e.zip
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 <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/node_messaging.h')
-rw-r--r--src/node_messaging.h3
1 files changed, 3 insertions, 0 deletions
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<v8::Value>& args);
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Drain(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void ReceiveMessage(const v8::FunctionCallbackInfo<v8::Value>& args);
/* static */
static void MoveToContext(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -200,6 +201,8 @@ class MessagePort : public HandleWrap {
void OnClose() override;
void OnMessage();
void TriggerAsync();
+ v8::MaybeLocal<v8::Value> ReceiveMessage(v8::Local<v8::Context> context,
+ bool only_if_receiving);
std::unique_ptr<MessagePortData> data_ = nullptr;
bool receiving_messages_ = false;