PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized > Struct Template Reference

Atomic specialization of a persistent ptr (self_relative_ptr) that manages its persistence by itself. More...

#include <libpmemobj++/experimental/atomic_persistent_aware_ptr.hpp>

Public Types

using this_type = atomic_persistent_aware_ptr
 
using value_type = pmem::obj::experimental::self_relative_ptr< T >
 
using difference_type = typename value_type::difference_type
 

Public Member Functions

 atomic_persistent_aware_ptr (value_type value)
 Constructors. More...
 
 atomic_persistent_aware_ptr (const atomic_persistent_aware_ptr &)=delete
 Deleted copy constructor.
 
template<typename OPT = ReadOptimized>
std::enable_if< std::is_same< OPT, std::true_type >::value >::type store (value_type desired, std::memory_order order=std::memory_order_seq_cst) noexcept
 Read-optimized store does the flush already in the store function. More...
 
template<typename OPT = ReadOptimized>
std::enable_if<!std::is_same< OPT, std::true_type >::value >::type store (value_type desired, std::memory_order order=std::memory_order_seq_cst) noexcept
 Write-optimized store relies on a consequent load to do the flush. More...
 
template<typename OPT = ReadOptimized>
std::enable_if< std::is_same< OPT, std::true_type >::value, value_type >::type load (std::memory_order order=std::memory_order_seq_cst) noexcept
 Read-optimized load. More...
 
template<typename OPT = ReadOptimized>
std::enable_if<!std::is_same< OPT, std::true_type >::value, value_type >::type load (std::memory_order order=std::memory_order_seq_cst) noexcept
 Write-optimized load flushes the data. More...
 
bool is_lock_free () const noexcept
 
 operator value_type () const noexcept
 Returns the value of the atomic_persistent_aware_ptr.
 
value_type operator= (value_type desired) noexcept
 Assignment operator. More...
 
atomic_persistent_aware_ptroperator= (const atomic_persistent_aware_ptr &)=delete
 Deleted assignment operator.
 

Detailed Description

template<typename T, typename ReadOptimized>
struct pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >

Atomic specialization of a persistent ptr (self_relative_ptr) that manages its persistence by itself.

In a multi-threaded scenario, the persistence of this ptr is guaranteed when it is visible to (or read by) other threads. Performance-wise, two different versions of this struct are provided:

  • Read-optimized - data is flushed along the write operation. If more reads are expected it's probably better to use this scenario.
  • Write-optimized - data is lazily flushed with a read operation. In this approach data storing is expected to be faster, but data is guaranteed to be flushed only after consequent read.

Constructor & Destructor Documentation

◆ atomic_persistent_aware_ptr()

template<typename T , typename ReadOptimized >
pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::atomic_persistent_aware_ptr ( value_type  value)
inline

Constructors.

Store constructor.

Parameters
valueto be stored in the atomic_persistent_aware_ptr.

Member Function Documentation

◆ load() [1/2]

template<typename T , typename ReadOptimized >
template<typename OPT = ReadOptimized>
std::enable_if<std::is_same<OPT, std::true_type>::value, value_type>::type pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::load ( std::memory_order  order = std::memory_order_seq_cst)
inlinenoexcept

Read-optimized load.

It relies on a store function to flush the data.

Returns
the value_type.

◆ load() [2/2]

template<typename T , typename ReadOptimized >
template<typename OPT = ReadOptimized>
std::enable_if<!std::is_same<OPT, std::true_type>::value, value_type>::type pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::load ( std::memory_order  order = std::memory_order_seq_cst)
inlinenoexcept

Write-optimized load flushes the data.

Returns
the value_type.

◆ operator=()

template<typename T , typename ReadOptimized >
value_type pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::operator= ( value_type  desired)
inlinenoexcept

Assignment operator.

Parameters
desiredvalue to be stored in the atomic_persistent_aware_ptr.
Returns
assigned value.

◆ store() [1/2]

template<typename T , typename ReadOptimized >
template<typename OPT = ReadOptimized>
std::enable_if<std::is_same<OPT, std::true_type>::value>::type pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::store ( value_type  desired,
std::memory_order  order = std::memory_order_seq_cst 
)
inlinenoexcept

Read-optimized store does the flush already in the store function.

Parameters
[in]desiredthe self_relative_ptr to be stored.

◆ store() [2/2]

template<typename T , typename ReadOptimized >
template<typename OPT = ReadOptimized>
std::enable_if<!std::is_same<OPT, std::true_type>::value>::type pmem::obj::experimental::atomic_persistent_aware_ptr< T, ReadOptimized >::store ( value_type  desired,
std::memory_order  order = std::memory_order_seq_cst 
)
inlinenoexcept

Write-optimized store relies on a consequent load to do the flush.

Parameters
[in]desiredthe self_relative_ptr to be stored.

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