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

Array of Dynamic Hazard Pointer guards. More...

#include <cds/gc/dhp.h>

Data Structures

struct  rebind
 Rebind array for other size OtherCount. 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 p 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 slot at index 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 guarded 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::DHP::GuardArray< Count >

Array of Dynamic Hazard Pointer guards.

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

A GuardArray object is not copy- and move-constructible and not copy- and move-assignable.

Member Function Documentation

◆ assign() [1/2]

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

Store p to the slot nIndex.

The function is just an assignment, no loop is performed.

◆ assign() [2/2]

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

Store marked pointer p to the guard.

The function is just an assignment of p.ptr(), no loop is performed. Can be used for a marked pointer that cannot be changed concurrently or for already guarded pointer.

◆ protect() [1/2]

template<size_t Count>
template<typename T >
T cds::gc::DHP::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::DHP::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 to make that conversion:

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

Actually, 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