Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/nodejs/src/cleanup_queue-inl.h
$ cat -n /usr/include/nodejs/src/cleanup_queue-inl.h 1 #ifndef SRC_CLEANUP_QUEUE_INL_H_ 2 #define SRC_CLEANUP_QUEUE_INL_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "base_object.h" 7 #include "cleanup_queue.h" 8 #include "memory_tracker-inl.h" 9 #include "util.h" 10 11 namespace node { 12 13 inline void CleanupQueue::MemoryInfo(MemoryTracker* tracker) const { 14 ForEachBaseObject([&](BaseObject* obj) { 15 if (obj->IsDoneInitializing()) tracker->Track(obj); 16 }); 17 } 18 19 inline size_t CleanupQueue::SelfSize() const { 20 return sizeof(CleanupQueue) + 21 cleanup_hooks_.size() * sizeof(CleanupHookCallback); 22 } 23 24 bool CleanupQueue::empty() const { 25 return cleanup_hooks_.empty(); 26 } 27 28 void CleanupQueue::Add(Callback cb, void* arg) { 29 auto insertion_info = 30 cleanup_hooks_.emplace(cb, arg, cleanup_hook_counter_++); 31 // Make sure there was no existing element with these values. 32 CHECK_EQ(insertion_info.second, true); 33 } 34 35 void CleanupQueue::Remove(Callback cb, void* arg) { 36 CleanupHookCallback search{cb, arg, 0}; 37 cleanup_hooks_.erase(search); 38 } 39 40 template
41 void CleanupQueue::ForEachBaseObject(T&& iterator) const { 42 std::vector
callbacks = GetOrdered(); 43 44 for (const auto& hook : callbacks) { 45 BaseObject* obj = GetBaseObject(hook); 46 if (obj != nullptr) iterator(obj); 47 } 48 } 49 50 BaseObject* CleanupQueue::GetBaseObject( 51 const CleanupHookCallback& callback) const { 52 if (callback.fn_ == BaseObject::DeleteMe) 53 return static_cast
(callback.arg_); 54 else 55 return nullptr; 56 } 57 58 } // namespace node 59 60 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 61 62 #endif // SRC_CLEANUP_QUEUE_INL_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™