Created
October 15, 2019 21:32
-
-
Save deepal/18c7d9eadc504b731316bdc0a4e257c7 to your computer and use it in GitHub Desktop.
Create message port between parent and child thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Worker::CreateEnvMessagePort(Environment* env) { | |
HandleScope handle_scope(isolate_); | |
Mutex::ScopedLock lock(mutex_); | |
// Set up the message channel for receiving messages in the child. | |
child_port_ = MessagePort::New(env, | |
env->context(), | |
std::move(child_port_data_)); | |
// MessagePort::New() may return nullptr if execution is terminated | |
// within it. | |
if (child_port_ != nullptr) | |
env->set_message_port(child_port_->object(isolate_)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment