summaryrefslogtreecommitdiff
path: root/src/env.h
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2017-11-22 18:41:00 +0100
committerAndreas Madsen <amwebdk@gmail.com>2017-12-19 18:04:52 +0100
commit3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be (patch)
tree1afc84002d1716f4acd28126df214127e0262c3c /src/env.h
parent0784b0440c05464f79b857f7d8698fcc953d3fb3 (diff)
downloadandroid-node-v8-3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be.tar.gz
android-node-v8-3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be.tar.bz2
android-node-v8-3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be.zip
async_hooks: use scope for defaultTriggerAsyncId
Previously the getter would mutate the kDefaultTriggerAsncId value. This refactor changes the setter to bind the current kDefaultTriggerAsncId to a scope, such that the getter doesn't have to mutate its own value. PR-URL: https://github.com/nodejs/node/pull/17273 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.h')
-rw-r--r--src/env.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/env.h b/src/env.h
index 7d7986bce4..8146229943 100644
--- a/src/env.h
+++ b/src/env.h
@@ -402,22 +402,23 @@ class Environment {
inline size_t stack_size();
inline void clear_async_id_stack(); // Used in fatal exceptions.
- // Used to propagate the trigger_async_id to the constructor of any newly
- // created resources using RAII. Instead of needing to pass the
- // trigger_async_id along with other constructor arguments.
- class InitScope {
+ // Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
+ // passing the trigger_async_id along with other constructor arguments.
+ class DefaultTriggerAsyncIdScope {
public:
- InitScope() = delete;
- explicit InitScope(Environment* env, double init_trigger_async_id);
- ~InitScope();
+ DefaultTriggerAsyncIdScope() = delete;
+ explicit DefaultTriggerAsyncIdScope(Environment* env,
+ double init_trigger_async_id);
+ ~DefaultTriggerAsyncIdScope();
private:
- Environment* env_;
AliasedBuffer<double, v8::Float64Array> async_id_fields_ref_;
+ double old_default_trigger_async_id_;
- DISALLOW_COPY_AND_ASSIGN(InitScope);
+ DISALLOW_COPY_AND_ASSIGN(DefaultTriggerAsyncIdScope);
};
+
private:
friend class Environment; // So we can call the constructor.
inline explicit AsyncHooks(v8::Isolate* isolate);
@@ -559,7 +560,6 @@ class Environment {
inline double execution_async_id();
inline double trigger_async_id();
inline double get_default_trigger_async_id();
- inline void set_default_trigger_async_id(const double id);
// List of id's that have been destroyed and need the destroy() cb called.
inline std::vector<double>* destroy_async_id_list();