diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-01-15 23:34:41 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-01-22 01:51:35 +0300 |
commit | de2c68c7dd17a217a818ea881e433034006fdb4b (patch) | |
tree | ac0fd540e61cb8365a8e966a116dfbfa62cd16c8 /src/node_worker.h | |
parent | 79a45e2cc3b048c3c1ffcc714e13dbf5f3b13b75 (diff) |
src: remove AsyncRequest
Remove `AsyncRequest` from the source code, and replace its
usage with threadsafe `SetImmediate()` calls. This has the
advantage of being able to pass in any function, rather than
one that is defined when the `AsyncRequest` is “installed”.
This necessitates two changes:
- The stopping flag (which was only used in one case and ignored
in the other) is now a direct member of the `Environment` class.
- Workers no longer have their own libuv handles, requiring
manual management of their libuv ref count.
As a drive-by fix, the `can_call_into_js` variable was turned
into an atomic variable. While there have been no bug reports,
the flag is set from `Stop(env)` calls, which are supposed to
be possible from any thread.
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_worker.h')
-rw-r--r-- | src/node_worker.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/node_worker.h b/src/node_worker.h index 7b1311734a2..632644202a5 100644 --- a/src/node_worker.h +++ b/src/node_worker.h @@ -41,7 +41,6 @@ class Worker : public AsyncWrap { void MemoryInfo(MemoryTracker* tracker) const override { tracker->TrackField("parent_port", parent_port_); - tracker->TrackInlineField(&on_thread_finished_, "on_thread_finished_"); } SET_MEMORY_INFO_NAME(Worker) @@ -107,14 +106,14 @@ class Worker : public AsyncWrap { // instance refers to it via its [kPort] property. MessagePort* parent_port_ = nullptr; - AsyncRequest on_thread_finished_; - // A raw flag that is used by creator and worker threads to // sync up on pre-mature termination of worker - while in the // warmup phase. Once the worker is fully warmed up, use the // async handle of the worker's Environment for the same purpose. bool stopped_ = true; + bool has_ref_ = true; + // The real Environment of the worker object. It has a lesser // lifespan than the worker object itself - comes to life // when the worker thread creates a new Environment, and gets |