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>,
83 : mMemPool(alloc.mMemPool)
91 mMemPool = alloc.mMemPool;
117 MemPoolParams memPoolParams = pvGetMemPoolParams();
118 bool equal = pvIsEqual(memPoolParams, mMemPool->GetParams());
119 if (!equal && mMemPool->GetAllocateCount() == 0)
125 return mMemPool->template Allocate<value_type>();
127 return MemManagerProxy::template Allocate<value_type>(mMemPool->GetMemManager(),
133 if (count == 1 && pvIsEqual(pvGetMemPoolParams(), mMemPool->GetParams()))
134 return mMemPool->Deallocate(ptr);
138 template<
typename Value,
typename... ValueArgs>
142 ::template Creator<ValueArgs...> ValueCreator;
143 ValueCreator(mMemPool->GetMemManager(), std::forward<ValueArgs>(valueArgs)...)(ptr);
146 template<
class Value>
155 return left.mMemPool == right.mMemPool;
161 return !(left == right);
180 return memPoolParams1.GetBlockSize() == memPoolParams2.GetBlockSize()
181 && memPoolParams1.GetBlockAlignment() == memPoolParams2.GetBlockAlignment();
185 std::shared_ptr<MemPool> mMemPool;
192 #endif // MOMO_INCLUDE_GUARD_STDISH_POOL_ALLOCATOR
Definition: ObjectManager.h:394
unsynchronized_pool_allocator(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:82
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:108
unsynchronized_pool_allocator & operator=(const unsynchronized_pool_allocator &alloc) noexcept
Definition: pool_allocator.h:89
friend bool operator==(const unsynchronized_pool_allocator &left, const unsynchronized_pool_allocator &right) noexcept
Definition: pool_allocator.h:152
size_t size_type
Definition: pool_allocator.h:62
Definition: Utility.h:238
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:179
static void Destroy(MemManager &memManager, Object &object) noexcept
Definition: ObjectManager.h:452
void destroy(Value *ptr) noexcept
Definition: pool_allocator.h:147
friend bool operator!=(const unsynchronized_pool_allocator &left, const unsynchronized_pool_allocator &right) noexcept
Definition: pool_allocator.h:158
MOMO_NODISCARD pointer allocate(size_type count)
Definition: pool_allocator.h:113
void deallocate(pointer ptr, size_type count) noexcept
Definition: pool_allocator.h:131
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:332
void construct(Value *ptr, ValueArgs &&... valueArgs)
Definition: pool_allocator.h:139
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:172
value_type * pointer
Definition: pool_allocator.h:59
unsynchronized_pool_allocator(const std::shared_ptr< MemPool > &memPool) noexcept
Definition: pool_allocator.h:165
std::true_type propagate_on_container_swap
Definition: pool_allocator.h:67
ptrdiff_t difference_type
Definition: pool_allocator.h:63
static void Deallocate(MemManager &memManager, Object *ptr, size_t size) noexcept
Definition: MemManager.h:424
unsynchronized_pool_allocator(const base_allocator_type &alloc=base_allocator_type())
Definition: pool_allocator.h:77
base_allocator_type get_base_allocator() const noexcept
Definition: pool_allocator.h:103
#define MOMO_NODISCARD
Definition: UserSettings.h:262
~unsynchronized_pool_allocator()=default