23#if defined(ONIXS_CMEMDH_ENABLE_TRACING)
34#include <OnixS/CME/MDH/Utils.h>
72#if defined(ONIXS_CMEMDH_ENABLE_TRACING)
76 virtual void trace(std::ostream& stream) = 0;
101template <class Object>
128 template <
class Other>
158 template <
class Other>
206 alignof(
value_type) <=
alignof(std::max_align_t),
207 "value_type must not require extended alignment"
210 assert(
nullptr != pool_);
212 if ONIXS_CMEMDH_UNLIKELY(qty >
max_size())
213 ::ONIXS_CMEMDH_NAMESPACE::details::throwMemoryPoolAllocatorSizeTooLarge();
225 Utils::unusedArgs(qty);
227 assert(
nullptr != pool_);
229 pool_->deallocate(block);
238 template <
class Item,
class... Args>
241 ::new (
static_cast<void*
>(block)) Item(std::forward<Args>(args)...);
250 std::is_nothrow_destructible<value_type>::value,
251 "value_type must be nothrow-destructible"
255 Utils::unusedArgs(obj);
275 template <
class Other>
286 template <
class LeftObject,
class RightObject>
300template <
class Object,
class OtherObject>
304 return (left.pool_ == right.pool_);
314template <
class Object,
class OtherObject>
318 return !(left == right);
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_NAMESPACE_END
#define ONIXS_CMEMDH_COLDPATH
#define ONIXS_CMEMDH_EXPORTED
#define ONIXS_CMEMDH_NORETURN
#define ONIXS_CMEMDH_NODISCARD
Adapts a MemoryPool for use as a standard allocator.
MemoryPoolAllocator & operator=(const MemoryPoolAllocator< Other > &other) noexcept
Replaces this allocator's pool association with a compatible source association.
void deallocate(pointer block, size_type qty) noexcept
Returns storage to the associated pool.
MemoryPoolAllocator(const MemoryPoolAllocator &other) noexcept=default
Copies the source allocator's pool association.
friend class MemoryPoolAllocator
void destroy(pointer obj) noexcept
Destroys an object without deallocating its storage.
const_pointer address(const_reference x) const noexcept
Obtains the address of a read-only object.
MemoryPoolAllocator(MemoryPool &memoryPool) noexcept
Associates the allocator with a pool.
pointer address(reference obj) const noexcept
Obtains the address of a mutable object.
pointer allocate(size_type qty)
Allocates uninitialized storage for a sequence of objects.
MemoryPool & memoryPool() const noexcept
MemoryPoolAllocator(const MemoryPoolAllocator< Other > &other) noexcept
Copies a compatible allocator's pool association.
const Order & const_reference
size_type max_size() const noexcept
const Order * const_pointer
friend bool operator==(const MemoryPoolAllocator< LeftObject > &left, const MemoryPoolAllocator< RightObject > &right) noexcept
~MemoryPoolAllocator() noexcept=default
Destroys the adapter without releasing its pool or outstanding storage.
std::ptrdiff_t difference_type
void construct(Item *block, Args &&... args)
Constructs an object in allocated storage.
MemoryPoolAllocator() noexcept
Creates an allocator that is not associated with a pool.
MemoryPoolAllocator & operator=(const MemoryPoolAllocator &other) noexcept=default
Replaces this allocator's pool association with the source association.
Configures allocation and caching behavior of the handler's memory pool.
Allocates and reclaims raw memory blocks.
virtual void release() noexcept=0
Destroys this pool and releases its storage.
MemoryPool() noexcept=default
Initializes the base of a concrete pool implementation.
virtual void * allocate(size_t size)=0
Obtains a raw memory block.
virtual void deallocate(void *block) noexcept=0
Returns a previously allocated block to its owning pool.
void throwMemoryPoolAllocatorSizeTooLarge()
MemoryPool * makeMemoryPool(const MemoryPoolSettings &settings)
Creates a memory pool using the supplied settings.
bool operator==(const MemoryPoolAllocator< Object > &left, const MemoryPoolAllocator< OtherObject > &right) noexcept
Tests whether two allocators use the same pool.
bool operator!=(const MemoryPoolAllocator< Object > &left, const MemoryPoolAllocator< OtherObject > &right) noexcept
Tests whether two allocators use different pools.
Produces an allocator for another object type using the same pool.
MemoryPoolAllocator< Other > other
Allocator type for Other.