Go to the documentation of this file.
16 #ifndef MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
17 #define MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
19 #include "../MemPool.h"
39 template<
typename TValue,
40 typename TBaseAllocator = std::allocator<unsigned char>,
67 template<
typename Value>
68 struct PoolAllocatorProxy
82 : mMemPool(alloc.mMemPool)
90 mMemPool = alloc.mMemPool;
98 return PoolAllocatorProxy<Value>(mMemPool);
115 MemPoolParams memPoolParams = pvGetMemPoolParams();
116 bool equal = pvIsEqual(memPoolParams, mMemPool->GetParams());
117 if (!equal && mMemPool->GetAllocateCount() == 0)
123 return mMemPool->template Allocate<value_type>();
125 return MemManagerProxy::template Allocate<value_type>(mMemPool->GetMemManager(),
131 if (count == 1 && pvIsEqual(pvGetMemPoolParams(), mMemPool->GetParams()))
132 return mMemPool->Deallocate(ptr);
136 template<
typename Value,
typename... ValueArgs>
140 ::template Creator<ValueArgs...> ValueCreator;
141 ValueCreator(mMemPool->GetMemManager(), std::forward<ValueArgs>(valueArgs)...)(ptr);
144 template<
class Value>
152 return mMemPool == alloc.mMemPool;
157 return !(*
this == alloc);
176 return memPoolParams1.GetBlockSize() == memPoolParams2.GetBlockSize()
177 && memPoolParams1.GetBlockAlignment() == memPoolParams2.GetBlockAlignment();
181 std::shared_ptr<MemPool> mMemPool;
188 #endif // MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
Definition: ObjectManager.h:196
unsynchronized_pool_allocator(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:81
Definition: MemPool.h:135
std::true_type propagate_on_container_move_assignment
Definition: pool_allocator.h:57
unsynchronized_pool_allocator select_on_container_copy_construction() const noexcept
Definition: pool_allocator.h:106
unsynchronized_pool_allocator & operator=(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:88
size_t size_type
Definition: pool_allocator.h:53
bool operator!=(const unsynchronized_pool_allocator &alloc) const noexcept
Definition: pool_allocator.h:155
const value_type * const_pointer
Definition: pool_allocator.h:51
TValue value_type
Definition: pool_allocator.h:45
MemManagerStd uses allocator<unsigned char>::allocate and deallocate
Definition: MemManager.h:176
static void Destroy(MemManager &memManager, Object &object) noexcept
Definition: ObjectManager.h:307
void destroy(Value *ptr) noexcept
Definition: pool_allocator.h:145
MOMO_NODISCARD pointer allocate(size_type count)
Definition: pool_allocator.h:111
void deallocate(pointer ptr, size_type count) noexcept
Definition: pool_allocator.h:129
std::false_type propagate_on_container_copy_assignment
Definition: pool_allocator.h:56
TBaseAllocator base_allocator_type
Definition: pool_allocator.h:47
Definition: MemManager.h:328
void construct(Value *ptr, ValueArgs &&... valueArgs)
Definition: pool_allocator.h:137
TMemPoolParams mem_pool_params
Definition: pool_allocator.h:48
Allocator with a pool of memory for containers like std::list, std::forward_list, std::map,...
Definition: pool_allocator.h:43
Definition: ObjectManager.h:143
value_type * pointer
Definition: pool_allocator.h:50
unsynchronized_pool_allocator(const std::shared_ptr< MemPool > &memPool) noexcept
Definition: pool_allocator.h:161
std::true_type propagate_on_container_swap
Definition: pool_allocator.h:58
#define MOMO_DECLARE_PROXY_CONSTRUCTOR(Object)
Definition: Utility.h:85
ptrdiff_t difference_type
Definition: pool_allocator.h:54
Definition: ArrayUtility.h:299
unsynchronized_pool_allocator(const base_allocator_type &alloc=base_allocator_type())
Definition: pool_allocator.h:76
bool operator==(const unsynchronized_pool_allocator &alloc) const noexcept
Definition: pool_allocator.h:150
static void Deallocate(MemManager &memManager, void *ptr, size_t size) noexcept
Definition: MemManager.h:423
base_allocator_type get_base_allocator() const noexcept
Definition: pool_allocator.h:101
#define MOMO_NODISCARD
Definition: UserSettings.h:192
~unsynchronized_pool_allocator()=default