cds
2.3.2
|
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. | |
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 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. | |
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.
|
inline |
Store p
to the slot nIndex
.
The function is just an assignment, no loop is performed.
|
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.
|
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 to make that conversion:
Actually, the result of f( toGuard.load())
is assigned to the hazard pointer.