|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Thread-local hazard pointer record with explicit memory ordering. More...
#include <safe_hazard_pointer.h>

Public Member Functions | |
| safe_hazard_pointer_record () | |
| void | protect (void *p, size_t slot=0) noexcept |
| Protect a pointer from reclamation. | |
| void | clear (size_t slot=0) noexcept |
| Clear hazard pointer protection. | |
| bool | contains (void *p) const noexcept |
| Check if a pointer is protected by this record. | |
| void * | get (size_t slot=0) const noexcept |
| Get protected pointer at slot. | |
Public Attributes | |
| std::atomic< safe_hazard_pointer_record * > | next {nullptr} |
| std::atomic< bool > | active {false} |
Static Public Attributes | |
| static constexpr size_t | MAX_HAZARD_POINTERS = 2 |
Private Attributes | |
| std::array< std::atomic< void * >, MAX_HAZARD_POINTERS > | hazard_pointers_ |
Thread-local hazard pointer record with explicit memory ordering.
Each thread maintains a small array of hazard pointers. All atomic operations use explicit memory_order for correctness on weak memory model architectures (ARM, etc.)
Definition at line 34 of file safe_hazard_pointer.h.
|
inline |
Definition at line 38 of file safe_hazard_pointer.h.
References active, hazard_pointers_, and next.
|
inlinenoexcept |
Clear hazard pointer protection.
| slot | Slot index |
Uses memory_order_release to ensure the clear is visible before any subsequent operations.
Definition at line 66 of file safe_hazard_pointer.h.
References hazard_pointers_, and MAX_HAZARD_POINTERS.
Referenced by kcenon::thread::safe_hazard_pointer_domain::acquire(), and kcenon::thread::safe_hazard_guard::clear().

|
inlinenodiscardnoexcept |
Check if a pointer is protected by this record.
| p | Pointer to check |
Uses memory_order_acquire to synchronize with protect() calls.
Definition at line 78 of file safe_hazard_pointer.h.
References hazard_pointers_.
|
inlinenodiscardnoexcept |
Get protected pointer at slot.
| slot | Slot index |
Definition at line 92 of file safe_hazard_pointer.h.
References hazard_pointers_, and MAX_HAZARD_POINTERS.
Referenced by kcenon::thread::safe_hazard_pointer_domain::collect_internal(), and kcenon::thread::safe_hazard_guard::get().

|
inlinenoexcept |
Protect a pointer from reclamation.
| p | Pointer to protect |
| slot | Slot index (0 or 1) |
Uses memory_order_release to ensure visibility to other threads scanning hazard pointers.
Definition at line 54 of file safe_hazard_pointer.h.
References hazard_pointers_, and MAX_HAZARD_POINTERS.
Referenced by kcenon::thread::safe_hazard_guard::protect(), and kcenon::thread::safe_hazard_guard::safe_hazard_guard().

| std::atomic<bool> kcenon::thread::safe_hazard_pointer_record::active {false} |
Definition at line 99 of file safe_hazard_pointer.h.
Referenced by kcenon::thread::safe_hazard_pointer_domain::acquire(), and safe_hazard_pointer_record().
|
private |
Definition at line 102 of file safe_hazard_pointer.h.
Referenced by clear(), contains(), get(), protect(), and safe_hazard_pointer_record().
|
staticconstexpr |
Definition at line 36 of file safe_hazard_pointer.h.
Referenced by clear(), kcenon::thread::safe_hazard_pointer_domain::collect_internal(), get(), and protect().
| std::atomic<safe_hazard_pointer_record*> kcenon::thread::safe_hazard_pointer_record::next {nullptr} |
Definition at line 98 of file safe_hazard_pointer.h.
Referenced by kcenon::thread::safe_hazard_pointer_domain::acquire(), kcenon::thread::safe_hazard_pointer_domain::collect_internal(), and safe_hazard_pointer_record().