|
Zero
0.1.0
|
Wrapper for gc_pointer_raw. More...
#include <w_gc_pool_forest.h>
Public Member Functions | |
| GcPointer () | |
| GcPointer (gc_pointer_raw raw) | |
| GcPointer (const GcPointer &other) | |
| GcPointer & | operator= (const GcPointer &other) |
| bool | operator== (const GcPointer &other) const |
| bool | operator!= (const GcPointer &other) const |
| bool | is_equal_address (const GcPointer &other) const |
| T * | dereference (GcPoolForest< T > &pool) const |
| void | set_mark (bool on) |
| bool | is_marked () const |
| gc_aba | get_aba () const |
| void | set_aba (gc_aba stamp) |
| gc_generation | get_generation () const |
| gc_segment | get_segment () const |
| gc_offset | get_offset () const |
| bool | is_null () const |
| gc_pointer_raw & | raw () |
| gc_pointer_raw | raw () const |
| bool | atomic_cas (const GcPointer &expected, const GcPointer &desired) |
| [Atomic] Compare and set for pointer, mark, and ABA counter altogether. See Figure 9.23 of [HERLIHY] More... | |
| GcPointer | atomic_swap (const GcPointer &new_ptr) |
| [Atomic] Atomic swap. More... | |
Protected Attributes | |
| gc_pointer_raw | _raw |
Wrapper for gc_pointer_raw.
| T | Type of the pointed class/struct. |
Methods whose name start with "atomic_" provide atomic semantics. Other method are NOT atomic. So, appropriately use memory barriers to protect your access. However, other methods are regular, meaning you will not see an utter garbage but only see either the old value or new value (some valid value other thread set). This is possible because this class contains only 8 bytes information. In x86_64, an aligned 8 byte access is always regular though not atomic.
When you want to call more than one non-atomic methods of GcPointer, it's a good idea to copy a shared GcPointer variable to a local GcPointer variable then access the local one. For example,
The copy/assignment operators of this class use the ACCESS_ONCE semantics to prohibit compiler from doing something dangerous for this purpose.
Still, CPU might do something and this is not atomic either. In case it matters, use the atomic_cas() or atomic_swap().
|
inlineexplicit |
Constructs with gc_pointer_raw.
Copy constructor. This is regular though might not be atomic.
|
inline |
[Atomic] Compare and set for pointer, mark, and ABA counter altogether. See Figure 9.23 of [HERLIHY]
| [in] | expected | test value |
| [in] | desired | if succeeds this value is set |
[Atomic] Atomic swap.
| [in] | new_ptr | the value to set |
|
inline |
De-references the pointer to return the actual object.
[Non-atomic] Returns the ABA counter.
|
inline |
[Non-atomic] Returns generation.
[Non-atomic] Returns offset.
|
inline |
[Non-atomic] Returns segment.
|
inline |
[Non-atomic] Equality operator that compares only the address part without ABA counter and mark.
[Non-atomic] Returns if the pointer is marked in the stashed boolen flag.
[Non-atomic] Tells if the pointer is null.
[Non-atomic] Inequality operator on the contained pointer value.
Copy assignment. This is regular though might not be atomic.
[Non-atomic] Equality operator on the contained pointer value.
|
inline |
[Non-atomic] Returns single integer representation.
|
inline |
[Non-atomic] Returns single integer representation.
[Non-atomic] Sets the ABA counter.
[Non-atomic] Marks the pointer for death, stashing TRUE into the pointer.
|
protected |
The pointer and stashed flags.
1.8.12