|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Single hazard pointer that protects one object from reclamation Uses RAII pattern - automatically releases protection on destruction. More...
#include <hazard_pointer.h>

Public Member Functions | |
| hazard_pointer () | |
| Default constructor - acquires a hazard pointer slot. | |
| hazard_pointer (hazard_pointer &&other) noexcept | |
| Move constructor. | |
| hazard_pointer & | operator= (hazard_pointer &&other) noexcept |
| Move assignment. | |
| ~hazard_pointer () | |
| Destructor - automatically releases protection. | |
| hazard_pointer (const hazard_pointer &)=delete | |
| Non-copyable. | |
| hazard_pointer & | operator= (const hazard_pointer &)=delete |
| template<typename T > | |
| void | protect (T *ptr) noexcept |
| Protect a pointer from reclamation. | |
| void | reset () noexcept |
| Release protection. | |
| bool | is_protected () const noexcept |
| Check if currently protecting a pointer. | |
| void * | get_protected () const noexcept |
| Get the protected pointer (may be null) | |
Private Attributes | |
| std::atomic< void * > * | slot_ |
| size_t | slot_index_ |
Static Private Attributes | |
| static const void * | SLOT_OWNED_MARKER = reinterpret_cast<void*>(0x1) |
Single hazard pointer that protects one object from reclamation Uses RAII pattern - automatically releases protection on destruction.
Definition at line 110 of file hazard_pointer.h.
| kcenon::thread::hazard_pointer::hazard_pointer | ( | ) |
Default constructor - acquires a hazard pointer slot.
Definition at line 241 of file hazard_pointer.cpp.
References kcenon::thread::detail::hazard_pointer_registry::get_thread_list(), kcenon::thread::detail::hazard_pointer_registry::instance(), kcenon::thread::detail::thread_hazard_list::MAX_HAZARDS_PER_THREAD, slot_, slot_index_, and SLOT_OWNED_MARKER.
Referenced by kcenon::thread::hazard_pointer_domain< T >::acquire().


|
noexcept |
Move constructor.
Definition at line 263 of file hazard_pointer.cpp.
| kcenon::thread::hazard_pointer::~hazard_pointer | ( | ) |
Destructor - automatically releases protection.
Definition at line 282 of file hazard_pointer.cpp.
References slot_.
|
delete |
Non-copyable.
|
noexcept |
Get the protected pointer (may be null)
Definition at line 304 of file hazard_pointer.cpp.
References slot_, and SLOT_OWNED_MARKER.
|
noexcept |
Check if currently protecting a pointer.
Definition at line 296 of file hazard_pointer.cpp.
References slot_, and SLOT_OWNED_MARKER.
Referenced by kcenon::thread::hazard_pointer_domain< T >::thread_retire_list::scan_and_reclaim().

|
delete |
|
noexcept |
Move assignment.
Definition at line 269 of file hazard_pointer.cpp.
|
inlinenoexcept |
Protect a pointer from reclamation.
| ptr | Pointer to protect |
Definition at line 137 of file hazard_pointer.h.
References slot_.
|
noexcept |
Release protection.
Definition at line 289 of file hazard_pointer.cpp.
References slot_, and SLOT_OWNED_MARKER.
|
private |
Definition at line 158 of file hazard_pointer.h.
Referenced by get_protected(), hazard_pointer(), is_protected(), protect(), reset(), and ~hazard_pointer().
|
private |
Definition at line 159 of file hazard_pointer.h.
Referenced by hazard_pointer().
|
inlinestaticprivate |
Definition at line 156 of file hazard_pointer.h.
Referenced by get_protected(), hazard_pointer(), is_protected(), and reset().