diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-01-15 23:34:41 +0300 |
---|---|---|
committer | Shelley Vohr <shelley.vohr@gmail.com> | 2020-02-17 21:54:14 +0300 |
commit | f8c45b277fbb59857355d35223c3429005bac6cd (patch) | |
tree | 3c7e903da360734a58175f4a69dc3033f59b192e /src/node_worker.h | |
parent | 600e96ec049a8985d17d2b0318e15f63db0c036b (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 |