cds  2.3.2
cds::gc::HP::GuardArray< Count > Class Template Reference

Array of Hazard Pointer guards. More...

#include <cds/gc/hp.h>

Data Structures

struct  rebind
 Rebind array for other size Count2. More...
 

Public Member Functions

 GuardArray ()
 Default ctor allocates Count hazard pointers.
 
 GuardArray (GuardArray &&)=delete
 Move ctor is prohibited.
 
GuardArrayoperator= (GuardArray &&)=delete
 Move assignment is prohibited.
 
 GuardArray (GuardArray const &)=delete
 Copy ctor is prohibited.
 
GuardArrayoperator= (GuardArray const &)=delete
 Copy assignment is prohibited.
 
 ~GuardArray ()
 Frees allocated hazard pointers.
 
template<typename T >
protect (size_t nIndex, atomics::atomic< T > const &toGuard)
 Protects a pointer of type atomic<T*> More...
 
template<typename T , class Func >
protect (size_t nIndex, atomics::atomic< T > const &toGuard, Func f)
 Protects a pointer of type atomic<T*> More...
 
template<typename T >
T * assign (size_t nIndex, T *p)
 Store to the slot nIndex. More...
 
template<typename T , int BITMASK>
T * assign (size_t nIndex, cds::details::marked_ptr< T, BITMASK > p)
 Store marked pointer p to the guard. More...
 
void copy (size_t nIndex, Guard const &src)
 Copy guarded value from src guard to slot at index nIndex.
 
void copy (size_t nDestIndex, size_t nSrcIndex)
 Copy guarded value from slot nSrcIndex to the slot nDestIndex.
 
void clear (size_t nIndex)
 Clear value of the slot nIndex.
 
template<typename T >
T * get (size_t nIndex) const
 Get current value of slot nIndex.
 
guarded_pointer get_native (size_t nIndex) const
 Get native hazard pointer stored.
 

Static Public Member Functions

static constexpr size_t capacity ()
 Capacity of the guard array.
 

Static Public Attributes

static constexpr const size_t c_nCapacity = Count
 Array capacity.
 

Detailed Description

template<size_t Count>
class cds::gc::HP::GuardArray< Count >

Array of Hazard Pointer guards.

The class is intended for allocating an array of hazard pointer guards. Template parameter Count defines the size of the array.

Member Function Documentation

◆ assign() [1/2]

template<size_t Count>
template<typename T >
T* cds::gc::HP::GuardArray< Count >::assign ( size_t  nIndex,
T *  p 
)
inline

Store to the slot nIndex.

The function equals to a simple assignment, no loop is performed.

◆ assign() [2/2]

template<size_t Count>
template<typename T , int BITMASK>
T* cds::gc::HP::GuardArray< Count >::assign ( size_t  nIndex,
cds::details::marked_ptr< T, BITMASK >  p 
)
inline

Store marked pointer p to the guard.

The function equals to a simple assignment of p.ptr(), no loop is performed. Can be used for a marked pointer that cannot be changed concurrently.

◆ protect() [1/2]

template<size_t Count>
template<typename T >
T cds::gc::HP::GuardArray< Count >::protect ( size_t  nIndex,
atomics::atomic< T > const &  toGuard 
)
inline

Protects a pointer of type atomic<T*>

Return the value of toGuard

The function tries to load toGuard and to store it to the slot nIndex repeatedly until the guard's value equals toGuard

◆ protect() [2/2]

template<size_t Count>
template<typename T , class Func >
T cds::gc::HP::GuardArray< Count >::protect ( size_t  nIndex,
atomics::atomic< T > const &  toGuard,
Func  f 
)
inline

Protects a pointer of type atomic<T*>

Return the value of toGuard

The function tries to load toGuard and to store it to the slot nIndex repeatedly until the guard's value equals toGuard

The function is useful for intrusive containers when toGuard is a node pointer that should be converted to a pointer to the value type before guarding. The parameter f of type Func is a functor that makes this conversion:

struct functor {
value_type * operator()( T * p );
};

Really, the result of f( toGuard.load()) is assigned to the hazard pointer.


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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:35 by Doxygen 1.8.13