|
cds
1.4.0
|
Hazard Pointer guard. More...
#include <cds/gc/hp.h>
Public Member Functions | |
| template<typename T > | |
| T | protect (std::atomic< T > const &toGuard) |
Protects a pointer of type atomic<T*> More... | |
| template<typename T , class Func > | |
| T | 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. | |
| ThreadGC & | getGC () 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. | |
Hazard Pointer guard.
This class is a wrapper for hzp::AutoHPGuard.
|
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
|
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.
|
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
|
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:
Really, the result of f( toGuard.load() ) is assigned to the hazard pointer.