summaryrefslogtreecommitdiff
path: root/src/node_messaging.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-04-18 00:54:59 +0200
committerMichaƫl Zasso <targos@protonmail.com>2019-05-18 13:59:47 +0200
commitb7ed4d71870aa3500adb38fdd6b5d1eddd779fa7 (patch)
treebd7fd7ef502430aebaba6de60162f2444f2b5126 /src/node_messaging.cc
parent1f935f899f2e7eaa0f20bbab148932508d85c022 (diff)
downloadnode-new-b7ed4d71870aa3500adb38fdd6b5d1eddd779fa7.tar.gz
worker: move `receiving_messages_` field to `MessagePort`
This is a property of the native object associated with the `MessagePort`, not something that should be set on the conceptual `MessagePort` that may be transferred around. PR-URL: https://github.com/nodejs/node/pull/27705 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_messaging.cc')
-rw-r--r--src/node_messaging.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/node_messaging.cc b/src/node_messaging.cc
index c7d0b32700..b9212ba272 100644
--- a/src/node_messaging.cc
+++ b/src/node_messaging.cc
@@ -588,9 +588,9 @@ void MessagePort::OnMessage() {
Mutex::ScopedLock lock(data_->mutex_);
Debug(this, "MessagePort has message, receiving = %d",
- static_cast<int>(data_->receiving_messages_));
+ static_cast<int>(receiving_messages_));
- if (!data_->receiving_messages_)
+ if (!receiving_messages_)
break;
if (data_->incoming_messages_.empty())
break;
@@ -722,17 +722,16 @@ void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
}
void MessagePort::Start() {
- Mutex::ScopedLock lock(data_->mutex_);
Debug(this, "Start receiving messages");
- data_->receiving_messages_ = true;
+ receiving_messages_ = true;
+ Mutex::ScopedLock lock(data_->mutex_);
if (!data_->incoming_messages_.empty())
TriggerAsync();
}
void MessagePort::Stop() {
- Mutex::ScopedLock lock(data_->mutex_);
Debug(this, "Stop receiving messages");
- data_->receiving_messages_ = false;
+ receiving_messages_ = false;
}
void MessagePort::Start(const FunctionCallbackInfo<Value>& args) {