PMDK C++ bindings  1.13.0-git65.g668e8cb6
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::detail::enumerable_thread_specific< T, Mutex, Storage > Class Template Reference

Class for storing thread local data. More...

#include <libpmemobj++/detail/enumerable_thread_specific.hpp>

Public Types

using value_type = T
 
using size_type = typename storage_type::size_type
 
using difference_type = typename storage_type::difference_type
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using iterator = typename storage_type::iterator
 
using const_iterator = typename storage_type::const_iterator
 

Public Member Functions

template<typename Handler >
void initialize (Handler handler=[](reference) {})
 Initialization method. More...
 
 enumerable_thread_specific ()
 Constructor.
 
reference local ()
 Returns data reference for the current thread. More...
 
bool empty () const
 Determines if container is empty or not. More...
 
void clear ()
 Removes all elements from the container. More...
 
size_type size () const
 Returns number of elements being stored in the container. More...
 
iterator begin ()
 Returns an iterator to the beginning. More...
 
iterator end ()
 Returns an iterator to element after the last. More...
 
const_iterator begin () const
 Returns an const_iterator to the beginning. More...
 
const_iterator end () const
 Returns an const_iterator to element after the last. More...
 

Detailed Description

template<typename T, typename Mutex = obj::shared_mutex, typename Storage = obj::segment_vector<T, obj::exponential_size_array_policy<>>>
class pmem::detail::enumerable_thread_specific< T, Mutex, Storage >

Class for storing thread local data.

Needed in concurrent containers for data consistency. Mutex - mutex that satisfies SharedMutex requirements. Storage - persistent container for storing threads data.

Precondition
T - must be default constructable.
Mutex must satisfy SharedMutex requirements.
Storage must provide methods: reference emplace_back(Args &&...) reference operator[](size_type) size_type size() bool empty() void clear()
Storage must support iterators
Reference to an object in Storage (obtained by operator[]) must be valid until this object is removed.

Member Function Documentation

◆ begin() [1/2]

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::iterator pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::begin

Returns an iterator to the beginning.

Returns
iterator to the first element in the container.

◆ begin() [2/2]

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::const_iterator pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::begin

Returns an const_iterator to the beginning.

Returns
const_iterator to the first element in the container.

◆ clear()

template<typename T , typename Mutex , typename Storage >
void pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::clear

Removes all elements from the container.

Not thread safe.

Postcondition
empty() == true.

◆ empty()

template<typename T , typename Mutex , typename Storage >
bool pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::empty

Determines if container is empty or not.

Returns
true if container is empty, false otherwise.

◆ end() [1/2]

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::iterator pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::end

Returns an iterator to element after the last.

Returns
iterator to the after last element in the container.

◆ end() [2/2]

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::const_iterator pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::end

Returns an const_iterator to element after the last.

Returns
const_iterator to the after last element in the container.

◆ initialize()

template<typename T , typename Mutex , typename Storage >
template<typename Handler >
void pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::initialize ( Handler  handler = [](reference) {})

Initialization method.

Uses handler functor to each element stored. It must be used to handle the remaining data after a crash and restore the initial state of a container.

Postcondition
empty() == true.

◆ local()

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::reference pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::local

Returns data reference for the current thread.

For the new thread, element by reference will be default constructed.

Precondition
must be called outside of a transaction.
Returns
reference to value for the current thread.

◆ size()

template<typename T , typename Mutex , typename Storage >
enumerable_thread_specific< T, Mutex, Storage >::size_type pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::size

Returns number of elements being stored in the container.

Returns
number of elements in container.

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