PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::obj::allocator< T, Policy, Traits > Class Template Reference

(EXPERIMENTAL) Encapsulates the information about the persistent memory allocation model using PMDK's libpmemobj. More...

#include <libpmemobj++/allocator.hpp>

Inheritance diagram for pmem::obj::allocator< T, Policy, Traits >:

Classes

struct  rebind
 Rebind to a different type. More...
 

Public Types

using size_type = typename AllocationPolicy::size_type
 
using pointer = typename AllocationPolicy::pointer
 
using value_type = typename AllocationPolicy::value_type
 
using const_void_pointer = persistent_ptr< const void >
 
using bool_type = bool
 
using const_pointer = persistent_ptr< const value_type >
 
using reference = value_type &
 
using const_reference = const value_type &
 

Public Member Functions

 allocator ()=default
 Defaulted constructor.
 
 ~allocator ()=default
 Defaulted destructor.
 
 allocator (allocator const &rhs)
 Copy constructor.
 
template<typename U >
 allocator (allocator< U > const &)
 Type converting constructor.
 
template<typename U , typename P , typename T2 >
 allocator (allocator< U, P, T2 > const &rhs)
 Type converting constructor.
 
pointer allocate (size_type cnt, const_void_pointer=0)
 Allocate storage for cnt objects of type T. More...
 
void deallocate (pointer p, size_type=0)
 Deallocates storage pointed to p, which must be a value returned by a previous call to allocate that has not been invalidated by an intervening call to deallocate. More...
 
size_type max_size () const
 The largest value that can meaningfully be passed to allocate(). More...
 
void construct (pointer p, const_reference t)
 Create an object at a specific address. More...
 
template<typename... Args>
void construct (pointer p, Args &&... args)
 Create an object at a specific address. More...
 
void destroy (pointer p)
 Destroy an object based on a pointer. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename P , typename Tr , typename T2 , typename P2 , typename Tr2 >
bool operator== (const allocator< T, P, Tr > &lhs, const allocator< T2, P2, Tr2 > &rhs)
 Determines if memory from another allocator can be deallocated from this one. More...
 
template<typename T , typename P , typename Tr , typename OtherAllocator >
bool operator!= (const allocator< T, P, Tr > &lhs, const OtherAllocator &rhs)
 Determines if memory from another allocator can be deallocated from this one. More...
 
template<typename T , typename T2 >
bool operator== (standard_alloc_policy< T > const &, standard_alloc_policy< T2 > const &)
 Determines if memory from another allocator can be deallocated from this one. More...
 
template<typename T , typename OtherAllocator >
bool operator== (standard_alloc_policy< T > const &, OtherAllocator const &)
 Determines if memory from another allocator can be deallocated from this one. More...
 

Detailed Description

template<typename T, typename Policy = standard_alloc_policy<T>, typename Traits = object_traits<T>>
class pmem::obj::allocator< T, Policy, Traits >

(EXPERIMENTAL) Encapsulates the information about the persistent memory allocation model using PMDK's libpmemobj.

This information includes the knowledge of the pointer type, their difference type, the type of the size of objects in this allocation model as well as memory allocation and deallocation primitives.

Member Function Documentation

◆ allocate()

template<typename T >
pointer pmem::obj::standard_alloc_policy< T >::allocate ( size_type  cnt,
const_void_pointer  = 0 
)
inlineinherited

Allocate storage for cnt objects of type T.

Does not construct the objects.

Parameters
[in]cntthe number of objects to allocate memory for.
Exceptions
transaction_scope_errorif called outside of an active transaction.
transaction_out_of_memoryif there is no free memory of requested size.
transaction_alloc_erroron transactional allocation failure.

◆ construct() [1/2]

template<typename T >
template<typename... Args>
void pmem::obj::object_traits< T >::construct ( pointer  p,
Args &&...  args 
)
inlineinherited

Create an object at a specific address.

This should be called only within a transaction.

Parameters
[in]pthe pointer to where the object will be constructed.
[in]argsparameters passed to the object's constructor.
Exceptions
transaction_scope_errorif called outside of an active transaction.
rethrowsexception from T constructor.

◆ construct() [2/2]

template<typename T >
void pmem::obj::object_traits< T >::construct ( pointer  p,
const_reference  t 
)
inlineinherited

Create an object at a specific address.

This should be called only within a transaction.

Parameters
[in]pthe pointer to where the object will be constructed.
[in]tthe object reference for copy construction.
Exceptions
transaction_scope_errorif called outside of an active transaction.
rethrowsexception from T constructor.

◆ deallocate()

template<typename T >
void pmem::obj::standard_alloc_policy< T >::deallocate ( pointer  p,
size_type  = 0 
)
inlineinherited

Deallocates storage pointed to p, which must be a value returned by a previous call to allocate that has not been invalidated by an intervening call to deallocate.

Parameters
[in]ppointer to the memory to be deallocated.
Exceptions
transaction_scope_errorif called outside of an active transaction.
transaction_free_erroron transactional free failure.

◆ destroy()

template<typename T >
void pmem::obj::object_traits< T >::destroy ( pointer  p)
inlineinherited

Destroy an object based on a pointer.

This should be called only within a transaction.

Parameters
[in]pthe pointer to the object to be destroyed.

◆ max_size()

template<typename T >
size_type pmem::obj::standard_alloc_policy< T >::max_size ( ) const
inlineinherited

The largest value that can meaningfully be passed to allocate().

Returns
largest value that can be passed to allocate.

Friends And Related Function Documentation

◆ operator!=()

template<typename T , typename P , typename Tr , typename OtherAllocator >
bool operator!= ( const allocator< T, P, Tr > &  lhs,
const OtherAllocator &  rhs 
)
related

Determines if memory from another allocator can be deallocated from this one.

Parameters
[in]lhsleft hand side allocator.
[in]rhsright hand side allocator.
Returns
false if allocators are equivalent in terms of deallocation, true otherwise.

◆ operator==() [1/3]

template<typename T , typename P , typename Tr , typename T2 , typename P2 , typename Tr2 >
bool operator== ( const allocator< T, P, Tr > &  lhs,
const allocator< T2, P2, Tr2 > &  rhs 
)
related

Determines if memory from another allocator can be deallocated from this one.

Parameters
[in]lhsleft hand side allocator.
[in]rhsright hand side allocator.
Returns
true if allocators are equivalent in terms of deallocation, false otherwise.

◆ operator==() [2/3]

template<typename T , typename OtherAllocator >
bool operator== ( standard_alloc_policy< T > const &  ,
OtherAllocator const &   
)
related

Determines if memory from another allocator can be deallocated from this one.

Returns
false.

◆ operator==() [3/3]

template<typename T , typename T2 >
bool operator== ( standard_alloc_policy< T > const &  ,
standard_alloc_policy< T2 > const &   
)
related

Determines if memory from another allocator can be deallocated from this one.

Returns
true.

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