Metall  v0.29
A persistent memory allocator for data-centric analytics
metall::stl_allocator< T, metall_manager_kernel_type > Class Template Reference

A STL compatible allocator. More...

#include </home/runner/work/metall/metall/include/metall/stl_allocator.hpp>

Classes

struct  rebind
 Makes another allocator type for type T2. More...
 

Public Types

using value_type = T
 
using pointer = typename std::pointer_traits< typename metall_manager_kernel_type::void_pointer >::template rebind< value_type >
 
using const_pointer = typename std::pointer_traits< pointer >::template rebind< const value_type >
 
using void_pointer = typename std::pointer_traits< pointer >::template rebind< void >
 
using const_void_pointer = typename std::pointer_traits< pointer >::template rebind< const void >
 
using difference_type = typename std::pointer_traits< pointer >::difference_type
 
using size_type = typename std::make_unsigned< difference_type >::type
 
using manager_kernel_type = metall_manager_kernel_type
 

Public Member Functions

 stl_allocator (manager_kernel_type *const *const pointer_manager_kernel_address) noexcept
 
template<typename T2 >
 stl_allocator (stl_allocator< T2, manager_kernel_type > allocator_instance) noexcept
 Construct a new instance using an instance that has a different T. More...
 
 stl_allocator (const stl_allocator &other) noexcept=default
 Copy constructor. More...
 
 stl_allocator (stl_allocator &&other) noexcept=default
 Move constructor. More...
 
 ~stl_allocator () noexcept=default
 Destructor. More...
 
stl_allocatoroperator= (const stl_allocator &) noexcept=default
 Copy assign operator. More...
 
template<typename T2 >
stl_allocatoroperator= (const stl_allocator< T2, manager_kernel_type > &other) noexcept
 Copy assign operator for another T. More...
 
stl_allocatoroperator= (stl_allocator &&other) noexcept=default
 Move assign operator. More...
 
template<typename T2 >
stl_allocatoroperator= (stl_allocator< T2, manager_kernel_type > &&other) noexcept
 Move assign operator for another T. More...
 
pointer allocate (const size_type n) const
 Allocates n * sizeof(T) bytes of storage. More...
 
void deallocate (pointer ptr, const size_type size) const
 Deallocates the storage reference by the pointer ptr. More...
 
size_type max_size () const noexcept
 The size of the theoretical maximum allocation size. More...
 
template<class... Args>
void construct (const pointer &ptr, Args &&...args) const
 Constructs an object of T. More...
 
void destroy (const pointer &ptr) const
 Deconstruct an object of T. More...
 
manager_kernel_type *const * get_pointer_to_manager_kernel () const
 Returns a pointer that points to manager kernel. More...
 

Detailed Description

template<typename T, typename metall_manager_kernel_type>
class metall::stl_allocator< T, metall_manager_kernel_type >

A STL compatible allocator.

Template Parameters
TA object type.
metall_manager_kernel_typeA manager kernel type.
Warning
This allocator does not define propagate_on_* types, as same as Boost.Interprocess. Those types are going to be std::false_type in std::allocator_traits. Therefore, this allocator is not propagated during containers' copy assignment, move assignment, or swap. This configuration enables users to copy containers between different Metall managers easier. On the other hand, performing the move assignment between two containers allocated by different Metall managers invokes copy operations instead of move operations. Also, swapping containers allocated by different Metall managers will result in undefined behavior.
Examples
allocator_aware_type.cpp, concurrent_map.cpp, multilevel_containers.cpp, string.cpp, string_map.cpp, and vector_of_vectors.cpp.

Member Typedef Documentation

◆ value_type

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::value_type = T

◆ pointer

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::pointer = typename std::pointer_traits< typename metall_manager_kernel_type::void_pointer>:: template rebind<value_type>

◆ const_pointer

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::const_pointer = typename std::pointer_traits<pointer>::template rebind<const value_type>

◆ void_pointer

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::void_pointer = typename std::pointer_traits<pointer>::template rebind<void>

◆ const_void_pointer

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::const_void_pointer = typename std::pointer_traits<pointer>::template rebind<const void>

◆ difference_type

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::difference_type = typename std::pointer_traits<pointer>::difference_type

◆ size_type

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::size_type = typename std::make_unsigned<difference_type>::type

◆ manager_kernel_type

template<typename T , typename metall_manager_kernel_type >
using metall::stl_allocator< T, metall_manager_kernel_type >::manager_kernel_type = metall_manager_kernel_type

Constructor & Destructor Documentation

◆ stl_allocator() [1/4]

template<typename T , typename metall_manager_kernel_type >
metall::stl_allocator< T, metall_manager_kernel_type >::stl_allocator ( manager_kernel_type *const *const  pointer_manager_kernel_address)
inlinenoexcept

◆ stl_allocator() [2/4]

template<typename T , typename metall_manager_kernel_type >
template<typename T2 >
metall::stl_allocator< T, metall_manager_kernel_type >::stl_allocator ( stl_allocator< T2, manager_kernel_type allocator_instance)
inlinenoexcept

Construct a new instance using an instance that has a different T.

◆ stl_allocator() [3/4]

template<typename T , typename metall_manager_kernel_type >
metall::stl_allocator< T, metall_manager_kernel_type >::stl_allocator ( const stl_allocator< T, metall_manager_kernel_type > &  other)
defaultnoexcept

Copy constructor.

◆ stl_allocator() [4/4]

template<typename T , typename metall_manager_kernel_type >
metall::stl_allocator< T, metall_manager_kernel_type >::stl_allocator ( stl_allocator< T, metall_manager_kernel_type > &&  other)
defaultnoexcept

Move constructor.

◆ ~stl_allocator()

template<typename T , typename metall_manager_kernel_type >
metall::stl_allocator< T, metall_manager_kernel_type >::~stl_allocator ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ operator=() [1/4]

template<typename T , typename metall_manager_kernel_type >
stl_allocator& metall::stl_allocator< T, metall_manager_kernel_type >::operator= ( const stl_allocator< T, metall_manager_kernel_type > &  )
defaultnoexcept

Copy assign operator.

◆ operator=() [2/4]

template<typename T , typename metall_manager_kernel_type >
template<typename T2 >
stl_allocator& metall::stl_allocator< T, metall_manager_kernel_type >::operator= ( const stl_allocator< T2, manager_kernel_type > &  other)
inlinenoexcept

Copy assign operator for another T.

◆ operator=() [3/4]

template<typename T , typename metall_manager_kernel_type >
stl_allocator& metall::stl_allocator< T, metall_manager_kernel_type >::operator= ( stl_allocator< T, metall_manager_kernel_type > &&  other)
defaultnoexcept

Move assign operator.

◆ operator=() [4/4]

template<typename T , typename metall_manager_kernel_type >
template<typename T2 >
stl_allocator& metall::stl_allocator< T, metall_manager_kernel_type >::operator= ( stl_allocator< T2, manager_kernel_type > &&  other)
inlinenoexcept

Move assign operator for another T.

◆ allocate()

template<typename T , typename metall_manager_kernel_type >
pointer metall::stl_allocator< T, metall_manager_kernel_type >::allocate ( const size_type  n) const
inline

Allocates n * sizeof(T) bytes of storage.

Parameters
nThe size to allocation
Returns
Returns a pointer

◆ deallocate()

template<typename T , typename metall_manager_kernel_type >
void metall::stl_allocator< T, metall_manager_kernel_type >::deallocate ( pointer  ptr,
const size_type  size 
) const
inline

Deallocates the storage reference by the pointer ptr.

Parameters
ptrA pointer to the storage
sizeThe size of the storage

◆ max_size()

template<typename T , typename metall_manager_kernel_type >
size_type metall::stl_allocator< T, metall_manager_kernel_type >::max_size ( ) const
inlinenoexcept

The size of the theoretical maximum allocation size.

Returns
The size of the theoretical maximum allocation size

◆ construct()

template<typename T , typename metall_manager_kernel_type >
template<class... Args>
void metall::stl_allocator< T, metall_manager_kernel_type >::construct ( const pointer ptr,
Args &&...  args 
) const
inline

Constructs an object of T.

Template Parameters
ArgsThe types of the constructor arguments
Parameters
ptrA pointer to allocated storage
argsThe constructor arguments to use

◆ destroy()

template<typename T , typename metall_manager_kernel_type >
void metall::stl_allocator< T, metall_manager_kernel_type >::destroy ( const pointer ptr) const
inline

Deconstruct an object of T.

Parameters
ptrA pointer to the object

◆ get_pointer_to_manager_kernel()

template<typename T , typename metall_manager_kernel_type >
manager_kernel_type* const* metall::stl_allocator< T, metall_manager_kernel_type >::get_pointer_to_manager_kernel ( ) const
inline

Returns a pointer that points to manager kernel.

Returns
A pointer that points to manager kernel

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