Go to the documentation of this file.
16 #ifndef MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
17 #define MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
20 # if __has_include(<momo/Utility.h>)
24 #ifndef MOMO_PARENT_HEADER
25 # include "../Utility.h"
28 #include MOMO_PARENT_HEADER(MemPool)
48 template<
typename TValue,
49 typename TBaseAllocator = std::allocator<unsigned char>,
76 template<
typename Value>
77 struct PoolAllocatorProxy
91 : mMemPool(alloc.mMemPool)
99 mMemPool = alloc.mMemPool;
103 template<
class Value>
107 return PoolAllocatorProxy<Value>(mMemPool);
124 MemPoolParams memPoolParams = pvGetMemPoolParams();
125 bool equal = pvIsEqual(memPoolParams, mMemPool->GetParams());
126 if (!equal && mMemPool->GetAllocateCount() == 0)
132 return mMemPool->template Allocate<value_type>();
134 return MemManagerProxy::template Allocate<value_type>(mMemPool->GetMemManager(),
140 if (count == 1 && pvIsEqual(pvGetMemPoolParams(), mMemPool->GetParams()))
141 return mMemPool->Deallocate(ptr);
145 template<
typename Value,
typename... ValueArgs>
149 ::template Creator<ValueArgs...> ValueCreator;
150 ValueCreator(mMemPool->GetMemManager(), std::forward<ValueArgs>(valueArgs)...)(ptr);
153 template<
class Value>
162 return left.mMemPool == right.mMemPool;
168 return !(left == right);
187 return memPoolParams1.GetBlockSize() == memPoolParams2.GetBlockSize()
188 && memPoolParams1.GetBlockAlignment() == memPoolParams2.GetBlockAlignment();
192 std::shared_ptr<MemPool> mMemPool;
199 #endif // MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
Definition: ObjectManager.h:240
unsynchronized_pool_allocator(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:90
Definition: MemPool.h:135
std::true_type propagate_on_container_move_assignment
Definition: pool_allocator.h:66
unsynchronized_pool_allocator select_on_container_copy_construction() const noexcept
Definition: pool_allocator.h:115
unsynchronized_pool_allocator & operator=(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:97
friend bool operator==(const unsynchronized_pool_allocator &left, const unsynchronized_pool_allocator &right) noexcept
Definition: pool_allocator.h:159
size_t size_type
Definition: pool_allocator.h:62
const value_type * const_pointer
Definition: pool_allocator.h:60
TValue value_type
Definition: pool_allocator.h:54
MemManagerStd uses allocator<unsigned char>::allocate and deallocate
Definition: MemManager.h:177
static void Destroy(MemManager &memManager, Object &object) noexcept
Definition: ObjectManager.h:351
void destroy(Value *ptr) noexcept
Definition: pool_allocator.h:154
friend bool operator!=(const unsynchronized_pool_allocator &left, const unsynchronized_pool_allocator &right) noexcept
Definition: pool_allocator.h:165
MOMO_NODISCARD pointer allocate(size_type count)
Definition: pool_allocator.h:120
void deallocate(pointer ptr, size_type count) noexcept
Definition: pool_allocator.h:138
std::false_type propagate_on_container_copy_assignment
Definition: pool_allocator.h:65
TBaseAllocator base_allocator_type
Definition: pool_allocator.h:56
Definition: MemManager.h:329
void construct(Value *ptr, ValueArgs &&... valueArgs)
Definition: pool_allocator.h:146
TMemPoolParams mem_pool_params
Definition: pool_allocator.h:57
Allocator with a pool of memory for containers like std::list, std::forward_list, std::map,...
Definition: pool_allocator.h:52
Definition: ObjectManager.h:171
value_type * pointer
Definition: pool_allocator.h:59
unsynchronized_pool_allocator(const std::shared_ptr< MemPool > &memPool) noexcept
Definition: pool_allocator.h:172
std::true_type propagate_on_container_swap
Definition: pool_allocator.h:67
#define MOMO_DECLARE_PROXY_CONSTRUCTOR(Object)
Definition: Utility.h:118
ptrdiff_t difference_type
Definition: pool_allocator.h:63
static void Deallocate(MemManager &memManager, Object *ptr, size_t size) noexcept
Definition: MemManager.h:425
unsynchronized_pool_allocator(const base_allocator_type &alloc=base_allocator_type())
Definition: pool_allocator.h:85
base_allocator_type get_base_allocator() const noexcept
Definition: pool_allocator.h:110
#define MOMO_NODISCARD
Definition: UserSettings.h:217
~unsynchronized_pool_allocator()=default