File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -809,6 +809,22 @@ bool Environment::CleanupHookCallback::Equal::operator()(
809809 return a.fn_ == b.fn_ && a.arg_ == b.arg_ ;
810810}
811811
812+ BaseObject* Environment::CleanupHookCallback::GetBaseObject () const {
813+ if (fn_ == BaseObject::DeleteMe)
814+ return static_cast <BaseObject*>(arg_);
815+ else
816+ return nullptr ;
817+ }
818+
819+ template <typename T>
820+ void Environment::ForEachBaseObject (T&& iterator) {
821+ for (const auto & hook : cleanup_hooks_) {
822+ BaseObject* obj = hook.GetBaseObject ();
823+ if (obj != nullptr )
824+ iterator (obj);
825+ }
826+ }
827+
812828#define VP (PropertyName, StringValue ) V(v8::Private, PropertyName)
813829#define VY (PropertyName, StringValue ) V(v8::Symbol, PropertyName)
814830#define VS (PropertyName, StringValue ) V(v8::String, PropertyName)
Original file line number Diff line number Diff line change @@ -976,6 +976,8 @@ class Environment {
976976 inline bool operator ()(const CleanupHookCallback& a,
977977 const CleanupHookCallback& b) const ;
978978 };
979+
980+ inline BaseObject* GetBaseObject () const ;
979981 };
980982
981983 // Use an unordered_set, so that we have efficient insertion and removal.
@@ -988,6 +990,9 @@ class Environment {
988990 v8::Local<v8::Promise> promise,
989991 v8::Local<v8::Value> parent);
990992
993+ template <typename T>
994+ void ForEachBaseObject (T&& iterator);
995+
991996#define V (PropertyName, TypeName ) Persistent<TypeName> PropertyName ## _;
992997 ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES (V)
993998#undef V
You can’t perform that action at this time.
0 commit comments