diff options
author | Gireesh Punathil <gpunathi@in.ibm.com> | 2018-06-12 09:01:46 -0400 |
---|---|---|
committer | Gireesh Punathil <gpunathi@in.ibm.com> | 2019-03-16 12:50:26 +0530 |
commit | d35af56e5f3b1334c4360dbf8a013d0c522fe5f8 (patch) | |
tree | a6f9bb5467ec693c04d6741c3704a7c80a4eb482 /src/env-inl.h | |
parent | 22de2cfb71f3f1ab63e9663f4aa62bd9016b762a (diff) | |
download | android-node-v8-d35af56e5f3b1334c4360dbf8a013d0c522fe5f8.tar.gz android-node-v8-d35af56e5f3b1334c4360dbf8a013d0c522fe5f8.tar.bz2 android-node-v8-d35af56e5f3b1334c4360dbf8a013d0c522fe5f8.zip |
src: shutdown node in-flight
This commit introduces a `node::Stop()` API.
An identified use case for embedders is their ability to tear down
Node while it is still running (event loop contain pending events)
Here the assumptions are that (i) embedders do not wish to resort to
JS routines to initiate shutdown (ii) embedders have the Environment
handle handy. (iii) embedders stop Node through a second thread.
Fixes: https://github.com/nodejs/node/issues/19365
Refs: https://github.com/nodejs/user-feedback/issues/51
PR-URL: https://github.com/nodejs/node/pull/21283
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com>
Diffstat (limited to 'src/env-inl.h')
-rw-r--r-- | src/env-inl.h | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/env-inl.h b/src/env-inl.h index 8c37b393dc..aff12e57bf 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -32,7 +32,6 @@ #include "v8.h" #include "node_perf_common.h" #include "node_context_data.h" -#include "node_worker.h" #include <cstddef> #include <cstdint> @@ -661,7 +660,7 @@ void Environment::SetUnrefImmediate(native_immediate_callback cb, } inline bool Environment::can_call_into_js() const { - return can_call_into_js_ && (is_main_thread() || !is_stopping_worker()); + return can_call_into_js_ && !is_stopping(); } inline void Environment::set_can_call_into_js(bool can_call_into_js) { @@ -709,9 +708,8 @@ inline void Environment::remove_sub_worker_context(worker::Worker* context) { sub_worker_contexts_.erase(context); } -inline bool Environment::is_stopping_worker() const { - CHECK(!is_main_thread()); - return worker_context_->is_stopped(); +inline bool Environment::is_stopping() const { + return thread_stopper_.IsStopped(); } inline performance::performance_state* Environment::performance_state() { |