cds
2.3.2
|
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. | |
GuardArray & | operator= (GuardArray &&)=delete |
Move assignment is prohibited. | |
GuardArray (GuardArray const &)=delete | |
Copy ctor is prohibited. | |
GuardArray & | operator= (GuardArray const &)=delete |
Copy assignment is prohibited. | |
~GuardArray () | |
Frees allocated hazard pointers. | |
template<typename T > | |
T | protect (size_t nIndex, atomics::atomic< T > const &toGuard) |
Protects a pointer of type atomic<T*> More... | |
template<typename T , class Func > | |
T | 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. | |
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.
|
inline |
Store to
the slot nIndex
.
The function equals to a simple assignment, no loop is performed.
|
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 slot nIndex
repeatedly until the guard's value equals 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
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:
Really, the result of f( toGuard.load())
is assigned to the hazard pointer.