diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-12-17 00:03:50 +0300 |
---|---|---|
committer | Shelley Vohr <shelley.vohr@gmail.com> | 2020-02-17 21:53:51 +0300 |
commit | 53e566bc50a8624394ff255059f4b6b2b3305068 (patch) | |
tree | 632397dd2811999eec4f8e873010d2cd40a153b6 /src/env.h | |
parent | 7ecf8424298df11232b5cdfc19f70379c77256ec (diff) |
src: better encapsulate native immediate list
Refactor for clarity and reusability. Make it more obvious that the
list is a FIFO queue.
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/env.h')
-rw-r--r-- | src/env.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/env.h b/src/env.h index 3fd042d186a..0a9ab754072 100644 --- a/src/env.h +++ b/src/env.h @@ -1427,8 +1427,20 @@ class Environment : public MemoryRetainer { Fn callback_; }; - std::unique_ptr<NativeImmediateCallback> native_immediate_callbacks_head_; - NativeImmediateCallback* native_immediate_callbacks_tail_ = nullptr; + class NativeImmediateQueue { + public: + inline std::unique_ptr<NativeImmediateCallback> Shift(); + inline void Push(std::unique_ptr<NativeImmediateCallback> cb); + // ConcatMove adds elements from 'other' to the end of this list, and clears + // 'other' afterwards. + inline void ConcatMove(NativeImmediateQueue&& other); + + private: + std::unique_ptr<NativeImmediateCallback> head_; + NativeImmediateCallback* tail_ = nullptr; + }; + + NativeImmediateQueue native_immediates_; void RunAndClearNativeImmediates(bool only_refed = false); static void CheckImmediate(uv_check_t* handle); |