5 #ifndef BITCOIN_SUPPORT_LOCKEDPOOL_H 6 #define BITCOIN_SUPPORT_LOCKEDPOOL_H 13 #include <unordered_map> 31 virtual void*
AllocateLocked(
size_t len,
bool *lockingSuccess) = 0;
36 virtual void FreeLocked(
void* addr,
size_t len) = 0;
71 void*
alloc(
size_t size);
96 typedef std::unordered_map<char*, SizeToChunkSortedMap::const_iterator>
ChunkToSizeMap;
172 void*
alloc(
size_t size);
178 void free(
void *ptr);
197 bool new_arena(
size_t size,
size_t align);
240 #endif // BITCOIN_SUPPORT_LOCKEDPOOL_H static std::once_flag init_flag
Definition: lockedpool.h:237
SizeToChunkSortedMap size_to_free_chunk
Definition: lockedpool.h:94
Definition: lockedpool.h:19
std::unique_ptr< LockedPageAllocator > allocator
Definition: lockedpool.h:183
Stats stats() const
Definition: lockedpool.cpp:128
size_t used
Definition: lockedpool.h:60
~LockedPool()
Definition: lockedpool.cpp:284
void * base
Definition: lockedpool.h:192
size_t total
Definition: lockedpool.h:149
Stats stats() const
Definition: lockedpool.cpp:323
size_t total
Definition: lockedpool.h:62
static bool LockingFailed()
Definition: lockedpool.cpp:384
size_t cumulative_bytes_locked
Definition: lockedpool.h:201
static const size_t ARENA_SIZE
Definition: lockedpool.h:134
std::multimap< size_t, char * > SizeToChunkSortedMap
Definition: lockedpool.h:92
size_t chunks_used
Definition: lockedpool.h:151
static void CreateInstance()
Definition: lockedpool.cpp:390
virtual ~LockedPageAllocator()
Definition: lockedpool.h:22
void free(void *ptr)
Definition: lockedpool.cpp:309
Definition: lockedpool.h:218
LockedPageArena(LockedPageAllocator *alloc_in, void *base_in, size_t size, size_t align)
Definition: lockedpool.cpp:367
~LockedPageArena()
Definition: lockedpool.cpp:371
void * alloc(size_t size)
Definition: lockedpool.cpp:287
char * base
Definition: lockedpool.h:106
size_t chunks_used
Definition: lockedpool.h:63
bool addressInArena(void *ptr) const
Definition: lockedpool.h:90
Definition: lockedpool.h:145
virtual ~Arena()
Definition: lockedpool.cpp:51
Definition: lockedpool.h:48
std::unordered_map< char *, size_t > chunks_used
Definition: lockedpool.h:103
void * alloc(size_t size)
Definition: lockedpool.cpp:55
LockedPool(std::unique_ptr< LockedPageAllocator > allocator, LockingFailed_Callback lf_cb_in=nullptr)
Definition: lockedpool.cpp:279
LockedPageAllocator * allocator
Definition: lockedpool.h:194
char * end
Definition: lockedpool.h:108
void free(void *ptr)
Definition: lockedpool.cpp:90
size_t chunks_free
Definition: lockedpool.h:152
static LockedPoolManager * _instance
Definition: lockedpool.h:236
ChunkToSizeMap chunks_free_end
Definition: lockedpool.h:100
bool new_arena(size_t size, size_t align)
Definition: lockedpool.cpp:338
size_t free
Definition: lockedpool.h:148
LockedPool & operator=(const LockedPool &)=delete
size_t size
Definition: lockedpool.h:193
virtual size_t GetLimit()=0
Arena & operator=(const Arena &)=delete
static const size_t ARENA_ALIGN
Definition: lockedpool.h:138
size_t chunks_free
Definition: lockedpool.h:64
std::unordered_map< char *, SizeToChunkSortedMap::const_iterator > ChunkToSizeMap
Definition: lockedpool.h:96
static LockedPoolManager & Instance()
Definition: lockedpool.h:222
ChunkToSizeMap chunks_free
Definition: lockedpool.h:98
LockingFailed_Callback lf_cb
Definition: lockedpool.h:200
Definition: lockedpool.h:126
Arena(void *base, size_t size, size_t alignment)
Definition: lockedpool.cpp:42
size_t free
Definition: lockedpool.h:61
virtual void FreeLocked(void *addr, size_t len)=0
virtual void * AllocateLocked(size_t len, bool *lockingSuccess)=0
std::list< LockedPageArena > arenas
Definition: lockedpool.h:199
size_t locked
Definition: lockedpool.h:150
size_t used
Definition: lockedpool.h:147
LockedPoolManager(std::unique_ptr< LockedPageAllocator > allocator)
Definition: lockedpool.cpp:379
std::mutex mutex
Definition: lockedpool.h:204
bool(* LockingFailed_Callback)()
Definition: lockedpool.h:142
Definition: lockedpool.h:58
size_t alignment
Definition: lockedpool.h:110
Definition: lockedpool.h:186