diff options
Diffstat (limited to 'src/js_native_api_v8_internals.h')
-rw-r--r-- | src/js_native_api_v8_internals.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/js_native_api_v8_internals.h b/src/js_native_api_v8_internals.h index ddd219818c..74afd1172e 100644 --- a/src/js_native_api_v8_internals.h +++ b/src/js_native_api_v8_internals.h @@ -28,6 +28,45 @@ namespace v8impl { +class RefTracker { + public: + RefTracker() {} + virtual ~RefTracker() {} + virtual void Finalize(bool isEnvTeardown) {} + + typedef RefTracker RefList; + + inline void Link(RefList* list) { + prev_ = list; + next_ = list->next_; + if (next_ != nullptr) { + next_->prev_ = this; + } + list->next_ = this; + } + + inline void Unlink() { + if (prev_ != nullptr) { + prev_->next_ = next_; + } + if (next_ != nullptr) { + next_->prev_ = prev_; + } + prev_ = nullptr; + next_ = nullptr; + } + + static void FinalizeAll(RefList* list) { + while (list->next_ != nullptr) { + list->next_->Finalize(true); + } + } + + private: + RefList* next_ = nullptr; + RefList* prev_ = nullptr; +}; + template <typename T> using Persistent = v8::Global<T>; |