@@ -537,87 +537,86 @@ class AsyncRequest : public MemoryRetainer {
537537 std::atomic_bool stopped_ {true };
538538};
539539
540- class Environment {
540+ class AsyncHooks {
541541 public:
542- Environment (const Environment&) = delete ;
543- Environment& operator =(const Environment&) = delete ;
542+ // Reason for both UidFields and Fields are that one is stored as a double*
543+ // and the other as a uint32_t*.
544+ enum Fields {
545+ kInit ,
546+ kBefore ,
547+ kAfter ,
548+ kDestroy ,
549+ kPromiseResolve ,
550+ kTotals ,
551+ kCheck ,
552+ kStackLength ,
553+ kFieldsCount ,
554+ };
544555
545- class AsyncHooks {
546- public:
547- // Reason for both UidFields and Fields are that one is stored as a double*
548- // and the other as a uint32_t*.
549- enum Fields {
550- kInit ,
551- kBefore ,
552- kAfter ,
553- kDestroy ,
554- kPromiseResolve ,
555- kTotals ,
556- kCheck ,
557- kStackLength ,
558- kFieldsCount ,
559- };
556+ enum UidFields {
557+ kExecutionAsyncId ,
558+ kTriggerAsyncId ,
559+ kAsyncIdCounter ,
560+ kDefaultTriggerAsyncId ,
561+ kUidFieldsCount ,
562+ };
560563
561- enum UidFields {
562- kExecutionAsyncId ,
563- kTriggerAsyncId ,
564- kAsyncIdCounter ,
565- kDefaultTriggerAsyncId ,
566- kUidFieldsCount ,
567- };
564+ inline AliasedBuffer<uint32_t , v8::Uint32Array>& fields ();
565+ inline AliasedBuffer<double , v8::Float64Array>& async_id_fields ();
566+ inline AliasedBuffer<double , v8::Float64Array>& async_ids_stack ();
568567
569- inline AliasedBuffer<uint32_t , v8::Uint32Array>& fields ();
570- inline AliasedBuffer<double , v8::Float64Array>& async_id_fields ();
571- inline AliasedBuffer<double , v8::Float64Array>& async_ids_stack ();
572-
573- inline v8::Local<v8::String> provider_string (int idx);
574-
575- inline void no_force_checks ();
576- inline Environment* env ();
577-
578- inline void push_async_ids (double async_id, double trigger_async_id);
579- inline bool pop_async_id (double async_id);
580- inline void clear_async_id_stack (); // Used in fatal exceptions.
581-
582- AsyncHooks (const AsyncHooks&) = delete ;
583- AsyncHooks& operator =(const AsyncHooks&) = delete ;
584-
585- // Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
586- // passing the trigger_async_id along with other constructor arguments.
587- class DefaultTriggerAsyncIdScope {
588- public:
589- DefaultTriggerAsyncIdScope () = delete ;
590- explicit DefaultTriggerAsyncIdScope (Environment* env,
591- double init_trigger_async_id);
592- explicit DefaultTriggerAsyncIdScope (AsyncWrap* async_wrap);
593- ~DefaultTriggerAsyncIdScope ();
594-
595- DefaultTriggerAsyncIdScope (const DefaultTriggerAsyncIdScope&) = delete ;
596- DefaultTriggerAsyncIdScope& operator =(const DefaultTriggerAsyncIdScope&) =
597- delete ;
598-
599- private:
600- AsyncHooks* async_hooks_;
601- double old_default_trigger_async_id_;
602- };
568+ inline v8::Local<v8::String> provider_string (int idx);
603569
570+ inline void no_force_checks ();
571+ inline Environment* env ();
604572
605- private:
606- friend class Environment ; // So we can call the constructor.
607- inline AsyncHooks ();
608- // Keep a list of all Persistent strings used for Provider types.
609- v8::Eternal<v8::String> providers_[AsyncWrap::PROVIDERS_LENGTH];
610- // Stores the ids of the current execution context stack.
611- AliasedBuffer<double , v8::Float64Array> async_ids_stack_;
612- // Attached to a Uint32Array that tracks the number of active hooks for
613- // each type.
614- AliasedBuffer<uint32_t , v8::Uint32Array> fields_;
615- // Attached to a Float64Array that tracks the state of async resources.
616- AliasedBuffer<double , v8::Float64Array> async_id_fields_;
573+ inline void push_async_ids (double async_id, double trigger_async_id);
574+ inline bool pop_async_id (double async_id);
575+ inline void clear_async_id_stack (); // Used in fatal exceptions.
617576
618- void grow_async_ids_stack ();
577+ AsyncHooks (const AsyncHooks&) = delete ;
578+ AsyncHooks& operator =(const AsyncHooks&) = delete ;
579+
580+ // Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
581+ // passing the trigger_async_id along with other constructor arguments.
582+ class DefaultTriggerAsyncIdScope {
583+ public:
584+ DefaultTriggerAsyncIdScope () = delete ;
585+ explicit DefaultTriggerAsyncIdScope (Environment* env,
586+ double init_trigger_async_id);
587+ explicit DefaultTriggerAsyncIdScope (AsyncWrap* async_wrap);
588+ ~DefaultTriggerAsyncIdScope ();
589+
590+ DefaultTriggerAsyncIdScope (const DefaultTriggerAsyncIdScope&) = delete ;
591+ DefaultTriggerAsyncIdScope& operator =(const DefaultTriggerAsyncIdScope&) =
592+ delete ;
593+
594+ private:
595+ AsyncHooks* async_hooks_;
596+ double old_default_trigger_async_id_;
619597 };
620598
599+ private:
600+ friend class Environment ; // So we can call the constructor.
601+ inline AsyncHooks ();
602+ // Keep a list of all Persistent strings used for Provider types.
603+ v8::Eternal<v8::String> providers_[AsyncWrap::PROVIDERS_LENGTH];
604+ // Stores the ids of the current execution context stack.
605+ AliasedBuffer<double , v8::Float64Array> async_ids_stack_;
606+ // Attached to a Uint32Array that tracks the number of active hooks for
607+ // each type.
608+ AliasedBuffer<uint32_t , v8::Uint32Array> fields_;
609+ // Attached to a Float64Array that tracks the state of async resources.
610+ AliasedBuffer<double , v8::Float64Array> async_id_fields_;
611+
612+ void grow_async_ids_stack ();
613+ };
614+
615+ class Environment {
616+ public:
617+ Environment (const Environment&) = delete ;
618+ Environment& operator =(const Environment&) = delete ;
619+
621620 class AsyncCallbackScope {
622621 public:
623622 AsyncCallbackScope () = delete ;
0 commit comments