PMDK C++ bindings  1.13.0-git23.gf49772ac
This is the C++ bindings documentation for PMDK's libpmemobj.
Public Member Functions | Private Member Functions | List of all members
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 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...
 

Private Member Functions

obj::pool_base get_pool () const noexcept
 Private helper function. More...
 
void set_cached_size (size_t s)
 Set cached storage size, persist it and make valgrind annotations.
 
size_t get_cached_size ()
 Get cached storage size and make valgrind annotations.
 

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.

◆ get_pool()

template<typename T , typename Mutex , typename Storage >
obj::pool_base pmem::detail::enumerable_thread_specific< T, Mutex, Storage >::get_pool
privatenoexcept

Private helper function.

Precondition
storage_type must reside in persistent memory pool.
Returns
reference to pool_base object where enumerable_thread_local resides.

◆ 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: