cds  1.4.0
Public Member Functions
cds::gc::HP::Guard Class Reference

Hazard Pointer guard. More...

#include <cds/gc/hp.h>

Inheritance diagram for cds::gc::HP::Guard:
cds::gc::hzp::AutoHPGuard

Public Member Functions

template<typename T >
protect (std::atomic< T > const &toGuard)
 Protects a pointer of type atomic<T*> More...
 
template<typename T , class Func >
protect (std::atomic< T > const &toGuard, Func f)
 Protects a converted pointer of type atomic<T*> More...
 
template<typename T >
T * assign (T *p)
 Store p to the guard. More...
 
void copy (Guard const &src)
 Copy from src guard to this guard.
 
template<typename T , int BITMASK>
T * assign (cds::details::marked_ptr< T, BITMASK > p)
 Store marked pointer p to the guard. More...
 
void clear ()
 Clear value of the guard.
 
template<typename T >
T * get () const
 Get the value currently protected.
 
guarded_pointer get_native () const
 Get native hazard pointer stored.
 
- Public Member Functions inherited from cds::gc::hzp::AutoHPGuard
 AutoHPGuard (ThreadGC &gc)
 Allocates HP guard from gc.
 
template<typename T >
 AutoHPGuard (ThreadGC &gc, T *p)
 Allocates HP guard from gc and protects the pointer p of type T.
 
 ~AutoHPGuard ()
 Frees HP guard. The pointer guarded may be deleted after this.
 
ThreadGCgetGC () const
 Returns thread GC.
 
template<typename T >
T * operator= (T *p)
 Protects the pointer p against reclamation (guards the pointer).
 

Additional Inherited Members

- Public Types inherited from cds::gc::hzp::AutoHPGuard
typedef
details::HPGuard::hazard_ptr 
hazard_ptr
 Hazard pointer type.
 

Detailed Description

Hazard Pointer guard.

This class is a wrapper for hzp::AutoHPGuard.

Member Function Documentation

template<typename T >
T* cds::gc::HP::Guard::assign ( T *  p)
inline

Store p to the guard.

The function equals to a simple assignment the value p to guard, no loop is performed. Can be used for a pointer that cannot be changed concurrently

template<typename T , int BITMASK>
T* cds::gc::HP::Guard::assign ( 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.

template<typename T >
T cds::gc::HP::Guard::protect ( std::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 HP slot repeatedly until the guard's value equals toGuard

template<typename T , class Func >
T cds::gc::HP::Guard::protect ( std::atomic< T > const &  toGuard,
Func  f 
)
inline

Protects a converted pointer of type atomic<T*>

Return the value of toGuard

The function tries to load toGuard and to store result of f functor to the HP slot 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 protecting. 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 1.4.0 Developed by Maxim Khiszinsky aka khizmax 2007 - 2012
Autogenerated Mon May 20 2013 00:37:58 by Doxygen 1.8.3.1