Include file:
#include "mcrl2/utilities/memory_pool.h
mcrl2::utilities::
memory_pool
¶The memory pool allocates elements of size T from blocks.
When ThreadSafe is true then the thread-safe guarantees will be satisfied.
mcrl2::utilities::memory_pool::
Block
¶typedef for std::array< Slot, ElementsPerBlock >
An array that stores ElementsPerBlock number of objects of type T.
mcrl2::utilities::memory_pool::
Freelist
¶typedef for typename detail::free_list< T >
mcrl2::utilities::memory_pool::
FreelistIt
¶typedef for typename Freelist::iterator
mcrl2::utilities::memory_pool::
SizeType
¶typedef for typename std::conditional< ThreadSafe, std::atomic< std::size_t >, std::size_t >::type
The last slot in the first block that has never been returned by allocate.
mcrl2::utilities::memory_pool::
Slot
¶typedef for typename Freelist::slot
mcrl2::utilities::memory_pool::
m_block_mutex
¶Ensures that the block list is only modified by a single thread.
mcrl2::utilities::memory_pool::
m_blocks
¶The list of blocks allocated by this pool.
mcrl2::utilities::memory_pool::
m_current_index
¶mcrl2::utilities::memory_pool::
m_freelist
¶Indicates the head of the freelist.
mcrl2::utilities::memory_pool::
m_number_of_blocks
¶Equal to the size of the blocks array to prevent iterating over the block list.
allocate
()¶Reuses memory from block and allocates a new block when no slots are free.
Returns: A pointer to a block of memory that can store an object of type T. threadsafe
capacity
() const noexcept¶Returns: The total number of elements that could be stored in this memory pool.
consolidate
()¶Frees blocks that are no longer storing elements of T.
Returns: The number of blocks that have been removed.
deallocate
(T *pointer)¶Free the memory used by the given pointer that has been allocated by this pool.
has_free_slots
() const noexcept¶Returns: True when thi memory pool has space for at least one more element without allocating new memory.
memory_pool
() = default¶memory_pool
(memory_pool &&other) = default¶operator=
(memory_pool &&other) = default¶~memory_pool
()¶Triggers the (possibly non-trivial) destructor of all elements stored in the pool.