Skip to content

Commit

Permalink
src: move ImmediateInfo out of Environment
Browse files Browse the repository at this point in the history
PR-URL: nodejs#26824
Refs: nodejs#26776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed Mar 27, 2019
1 parent 0fa0fe0 commit 4999a89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
20 changes: 10 additions & 10 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,39 +232,39 @@ inline void Environment::PopAsyncCallbackScope() {
async_callback_scope_depth_--;
}

inline Environment::ImmediateInfo::ImmediateInfo(v8::Isolate* isolate)
inline ImmediateInfo::ImmediateInfo(v8::Isolate* isolate)
: fields_(isolate, kFieldsCount) {}

inline AliasedBuffer<uint32_t, v8::Uint32Array>&
Environment::ImmediateInfo::fields() {
ImmediateInfo::fields() {
return fields_;
}

inline uint32_t Environment::ImmediateInfo::count() const {
inline uint32_t ImmediateInfo::count() const {
return fields_[kCount];
}

inline uint32_t Environment::ImmediateInfo::ref_count() const {
inline uint32_t ImmediateInfo::ref_count() const {
return fields_[kRefCount];
}

inline bool Environment::ImmediateInfo::has_outstanding() const {
inline bool ImmediateInfo::has_outstanding() const {
return fields_[kHasOutstanding] == 1;
}

inline void Environment::ImmediateInfo::count_inc(uint32_t increment) {
inline void ImmediateInfo::count_inc(uint32_t increment) {
fields_[kCount] += increment;
}

inline void Environment::ImmediateInfo::count_dec(uint32_t decrement) {
inline void ImmediateInfo::count_dec(uint32_t decrement) {
fields_[kCount] -= decrement;
}

inline void Environment::ImmediateInfo::ref_count_inc(uint32_t increment) {
inline void ImmediateInfo::ref_count_inc(uint32_t increment) {
fields_[kRefCount] += increment;
}

inline void Environment::ImmediateInfo::ref_count_dec(uint32_t decrement) {
inline void ImmediateInfo::ref_count_dec(uint32_t decrement) {
fields_[kRefCount] -= decrement;
}

Expand Down Expand Up @@ -435,7 +435,7 @@ inline AsyncHooks* Environment::async_hooks() {
return &async_hooks_;
}

inline Environment::ImmediateInfo* Environment::immediate_info() {
inline ImmediateInfo* Environment::immediate_info() {
return &immediate_info_;
}

Expand Down
53 changes: 23 additions & 30 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,29 @@ class AsyncCallbackScope {
Environment* env_;
};

class ImmediateInfo {
public:
inline AliasedBuffer<uint32_t, v8::Uint32Array>& fields();
inline uint32_t count() const;
inline uint32_t ref_count() const;
inline bool has_outstanding() const;
inline void count_inc(uint32_t increment);
inline void count_dec(uint32_t decrement);
inline void ref_count_inc(uint32_t increment);
inline void ref_count_dec(uint32_t decrement);

ImmediateInfo(const ImmediateInfo&) = delete;
ImmediateInfo& operator=(const ImmediateInfo&) = delete;

private:
friend class Environment; // So we can call the constructor.
inline explicit ImmediateInfo(v8::Isolate* isolate);

enum Fields { kCount, kRefCount, kHasOutstanding, kFieldsCount };

AliasedBuffer<uint32_t, v8::Uint32Array> fields_;
};

class Environment {
public:
Environment(const Environment&) = delete;
Expand All @@ -628,36 +651,6 @@ class Environment {
inline void PushAsyncCallbackScope();
inline void PopAsyncCallbackScope();

class ImmediateInfo {
public:
inline AliasedBuffer<uint32_t, v8::Uint32Array>& fields();
inline uint32_t count() const;
inline uint32_t ref_count() const;
inline bool has_outstanding() const;

inline void count_inc(uint32_t increment);
inline void count_dec(uint32_t decrement);

inline void ref_count_inc(uint32_t increment);
inline void ref_count_dec(uint32_t decrement);

ImmediateInfo(const ImmediateInfo&) = delete;
ImmediateInfo& operator=(const ImmediateInfo&) = delete;

private:
friend class Environment; // So we can call the constructor.
inline explicit ImmediateInfo(v8::Isolate* isolate);

enum Fields {
kCount,
kRefCount,
kHasOutstanding,
kFieldsCount
};

AliasedBuffer<uint32_t, v8::Uint32Array> fields_;
};

class TickInfo {
public:
inline AliasedBuffer<uint8_t, v8::Uint8Array>& fields();
Expand Down

0 comments on commit 4999a89

Please sign in to comment.