File tree Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -714,8 +714,7 @@ ThreadId AllocateEnvironmentThreadId() {
714714}
715715
716716void DefaultProcessExitHandler (Environment* env, int exit_code) {
717- env->set_can_call_into_js (false );
718- env->stop_sub_worker_contexts ();
717+ Stop (env);
719718 DisposePlatform ();
720719 exit (exit_code);
721720}
Original file line number Diff line number Diff line change @@ -523,9 +523,10 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
523523 }
524524}
525525
526- void Environment::ExitEnv () {
526+ void Environment::Stop () {
527527 set_can_call_into_js (false );
528528 set_stopping (true );
529+ stop_sub_worker_contexts ();
529530 isolate_->TerminateExecution ();
530531 SetImmediateThreadsafe ([](Environment* env) { uv_stop (env->event_loop ()); });
531532}
Original file line number Diff line number Diff line change @@ -913,7 +913,7 @@ class Environment : public MemoryRetainer {
913913 void RegisterHandleCleanups ();
914914 void CleanupHandles ();
915915 void Exit (int code);
916- void ExitEnv ();
916+ void Stop ();
917917
918918 // Register clean-up cb to be called on environment destruction.
919919 inline void RegisterHandleCleanup (uv_handle_t * handle,
Original file line number Diff line number Diff line change @@ -1035,7 +1035,7 @@ int Start(int argc, char** argv) {
10351035}
10361036
10371037int Stop (Environment* env) {
1038- env->ExitEnv ();
1038+ env->Stop ();
10391039 return 0 ;
10401040}
10411041
Original file line number Diff line number Diff line change @@ -218,7 +218,8 @@ class Environment;
218218NODE_EXTERN int Start (int argc, char * argv[]);
219219
220220// Tear down Node.js while it is running (there are active handles
221- // in the loop and / or actively executing JavaScript code).
221+ // in the loop and / or actively executing JavaScript code). This also stops
222+ // all Workers that may have been started earlier.
222223NODE_EXTERN int Stop (Environment* env);
223224
224225// TODO(addaleax): Officially deprecate this and replace it with something
@@ -457,8 +458,8 @@ NODE_EXTERN void FreeEnvironment(Environment* env);
457458// It receives the Environment* instance and the exit code as arguments.
458459// This could e.g. call Stop(env); in order to terminate execution and stop
459460// the event loop.
460- // The default handler disposes of the global V8 platform instance, if one is
461- // being used, and calls exit().
461+ // The default handler calls Stop(), disposes of the global V8 platform
462+ // instance, if one is being used, and calls exit().
462463NODE_EXTERN void SetProcessExitHandler (
463464 Environment* env,
464465 std::function<void (Environment*, int )>&& handler);
You can’t perform that action at this time.
0 commit comments