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