5 #ifndef INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
6 #define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
12 #include "cppgc/internal/logging.h"
13 #include "cppgc/trace-trait.h"
22 class CrossThreadPersistentRegion;
23 class FatalOutOfMemoryHandler;
28 class PersistentNode
final {
33 PersistentNode&
operator=(
const PersistentNode&) =
delete;
58 trace_(visitor, owner_);
61 bool IsUsed()
const {
return trace_; }
76 TraceCallback trace_ =
nullptr;
80 using PersistentNodeSlots = std::array<PersistentNode, 256u>;
99 TraceCallback trace) {
100 PersistentNode* node =
nullptr;
102 node = free_list_head_;
115 free_list_head_ = node;
121 TraceCallback trace);
124 template <
typename PersistentBaseClass>
125 void ClearAllUsedNodes();
127 void RefillFreeList();
129 std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
130 PersistentNode* free_list_head_ =
nullptr;
131 size_t nodes_in_use_ = 0;
132 const FatalOutOfMemoryHandler& oom_handler_;
134 friend class CrossThreadPersistentRegion;
146 PersistentRegion&
operator=(
const PersistentRegion&) =
delete;
164 bool IsCreationThread();
166 int creation_thread_id_;
189 CrossThreadPersistentRegion&
operator=(
const CrossThreadPersistentRegion&) =