summaryrefslogtreecommitdiff
path: root/src/node_worker.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-08 19:22:35 +0100
committerAnna Henningsen <anna@addaleax.net>2019-02-11 19:57:14 +0100
commit58ba8bfc46c06bf9f75887c18df563d91a1f782c (patch)
tree30e85762e7807e4c6e1c821d1fbf69fc33409ec9 /src/node_worker.cc
parente11388b245d9822fcaf2209baaa9e1958d102d2d (diff)
downloadandroid-node-v8-58ba8bfc46c06bf9f75887c18df563d91a1f782c.tar.gz
android-node-v8-58ba8bfc46c06bf9f75887c18df563d91a1f782c.tar.bz2
android-node-v8-58ba8bfc46c06bf9f75887c18df563d91a1f782c.zip
worker: pre-allocate thread id
Allocate a thread id before actually creating the Environment instance. PR-URL: https://github.com/nodejs/node/pull/26011 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r--src/node_worker.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 3fd19de97c..36b4106d13 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -71,7 +71,8 @@ Worker::Worker(Environment* env,
Local<Object> wrap,
const std::string& url,
std::shared_ptr<PerIsolateOptions> per_isolate_opts)
- : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_WORKER), url_(url) {
+ : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_WORKER), url_(url),
+ thread_id_(Environment::AllocateThreadId()) {
Debug(this, "Creating new worker instance at %p", static_cast<void*>(this));
// Set up everything that needs to be set up in the parent environment.
@@ -114,11 +115,11 @@ Worker::Worker(Environment* env,
Context::Scope context_scope(context);
// TODO(addaleax): Use CreateEnvironment(), or generally another public API.
- env_.reset(new Environment(isolate_data_.get(), context));
+ env_.reset(new Environment(
+ isolate_data_.get(), context, Flags::kNoFlags, thread_id_));
CHECK_NOT_NULL(env_);
env_->set_abort_on_uncaught_exception(false);
env_->set_worker_context(this);
- thread_id_ = env_->thread_id();
env_->Start(env->profiler_idle_notifier_started());
env_->ProcessCliArgs(std::vector<std::string>{},