12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
21#if HX_CPLUSPLUS >= 202002L
31#define hxfree_list_concept_ typename
44template<hxfree_list_concept_ T_, hx
size_t capacity_=hxallocator_dynamic_capacity>
61 operator bool(
void)
const {
return true; }
88 template<
typename... args_t_>
106 template<
typename deleter_t_>
118 template<
typename deleter_t_>
138 template<
typename... args_t_>
152 void enqueue_all_(
hxsize_t count_)
noexcept;
158#include "detail/hxfree_list.inl"
hxallocator(void)
Does not allocate until reserve_storage is called.
Definition hxallocator.hpp:78
deleter_t - A callable deleter that releases a T back to this hxfree_list.
Definition hxfree_list.hpp:49
deleter_t(hxfree_list &owner_) noexcept
Constructs a deleter associated with owner.
Definition hxfree_list.hpp:53
void operator()(T *p_) noexcept
Destructs *p and returns its slot to the owning hxfree_list.
Definition hxfree_list.hpp:58
hxsize_t capacity(void) const
Returns the capacity of the pool or 0 if unallocated.
hxfree_list(void) noexcept
When capacity is hxallocator_dynamic_capacity storage must be allocated via reserve before use.
T value_t
value_t - Publishes the value type.
Definition hxfree_list.hpp:68
bool empty(void) const
Returns true if no unallocated T remains.
Definition hxfree_list.hpp:98
hxptr< T, deleter_t > try_allocate(args_t_ &&... args_) noexcept
Constructs a T in a free slot and returns an hxptr owning it.
hxsize_t size(void) const
Returns the number of unallocated T available.
Definition hxfree_list.hpp:133
bool is_allocator(const hxptr< T, deleter_t_ > &ptr_) const noexcept
Returns true if ptr points into this free list's storage.
hxptr< T, deleter_t > ptr_t
ptr_t - Publish the hxptr type.
Definition hxfree_list.hpp:71
hxsize_t max_size(void) const
Returns the capacity of the pool.
Definition hxfree_list.hpp:110
deleter_t deleter(void) noexcept
Returns a deleter_t associated with this hxfree_list.
Definition hxfree_list.hpp:95
void reserve(hxsize_t size_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment) noexcept
Allocates storage for size slots and enqueues them when capacity is hxallocator_dynamic_capacity.
void release(hxptr< T, deleter_t_ > &&ptr_) noexcept
Destructs the object owned by ptr and returns its slot to the free list.
hxptr< T, deleter_t > allocate(args_t_ &&... args_) noexcept
Constructs a T in a free slot and returns an hxptr owning it.
void release(T *p_) noexcept
Destructs *p and returns its slot to the free list.
hxfree_list(hxfree_list &&x_) noexcept
Move constructs from a temporary hxfree_list.
~hxfree_list(void) noexcept
All T must have been released before destruction.
bool is_allocator(const T *p_) const noexcept
Returns true if p points into this free list's storage.
hxptr<T, deleter_t> - A unique owning pointer.
Definition hxptr.hpp:30
hxfree_list_concept - Concept smoke testing the hxfree_list element.
Definition hxfree_list.hpp:26
Similar to std::allocator.
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:82
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:77
unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:64
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:69
#define hxattr_nonnull(...)
hxattr_nonnull - Indicates that a function has args that should not be null.
Definition hxsettings.h:97
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
Provides core macros, memory management and feature detection.
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric constant 0.
Definition libhatchet.h:277
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209