mCRL2
Loading...
Searching...
No Matches
mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe > Class Template Reference

The block allocator provides the allocator interface for the memory pool class. As such is can be used as an allocator for allocator aware storages. More...

#include <block_allocator.h>

Inheritance diagram for mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >:
mcrl2::utilities::memory_pool< T, ElementsPerBlock, ThreadSafe > mcrl2::utilities::noncopyable

Classes

struct  rebind
 

Public Types

using value_type = T
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

 block_allocator ()=default
 
T * allocate (size_type n, const void *hint=nullptr)
 
void deallocate (T *p, size_type)
 
 block_allocator (block_allocator &&)=default
 
block_allocatoroperator= (block_allocator &&)=default
 
- Public Member Functions inherited from mcrl2::utilities::memory_pool< T, ElementsPerBlock, ThreadSafe >
 memory_pool ()=default
 
 ~memory_pool ()
 Triggers the (possibly non-trivial) destructor of all elements stored in the pool.
 
T * allocate ()
 Reuses memory from block and allocates a new block when no slots are free.
 
void deallocate (T *pointer)
 Free the memory used by the given pointer that has been allocated by this pool.
 
std::size_t consolidate ()
 Frees blocks that are no longer storing elements of T.
 
bool has_free_slots () const noexcept
 
std::size_t capacity () const noexcept
 
 memory_pool (memory_pool &&other)=default
 
memory_pooloperator= (memory_pool &&other)=default
 

Private Types

using super = memory_pool< T, ElementsPerBlock, ThreadSafe >
 

Detailed Description

template<class T, std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
class mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >

The block allocator provides the allocator interface for the memory pool class. As such is can be used as an allocator for allocator aware storages.

Also provides several non-standard allocate functions specifically for the term pool.

Definition at line 29 of file block_allocator.h.

Member Typedef Documentation

◆ difference_type

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
using mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::difference_type = std::ptrdiff_t

Definition at line 37 of file block_allocator.h.

◆ size_type

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
using mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::size_type = std::size_t

Definition at line 36 of file block_allocator.h.

◆ super

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
using mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::super = memory_pool<T, ElementsPerBlock, ThreadSafe>
private

Definition at line 32 of file block_allocator.h.

◆ value_type

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
using mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::value_type = T

Definition at line 35 of file block_allocator.h.

Constructor & Destructor Documentation

◆ block_allocator() [1/2]

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::block_allocator ( )
default

◆ block_allocator() [2/2]

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::block_allocator ( block_allocator< T, ElementsPerBlock, ThreadSafe > &&  )
default

Member Function Documentation

◆ allocate()

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
T * mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::allocate ( size_type  n,
const void *  hint = nullptr 
)
inline

The unused parameter is to make the interface equivalent to the allocator.

Definition at line 49 of file block_allocator.h.

◆ deallocate()

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
void mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::deallocate ( T *  p,
size_type   
)
inline

The unused parameter is to make the interface equivalent to the allocator.

Definition at line 61 of file block_allocator.h.

◆ operator=()

template<class T , std::size_t ElementsPerBlock = 1024, bool ThreadSafe = false>
block_allocator & mcrl2::utilities::block_allocator< T, ElementsPerBlock, ThreadSafe >::operator= ( block_allocator< T, ElementsPerBlock, ThreadSafe > &&  )
default

The documentation for this class was generated from the following file: