Tervel
1.0.0
A collection of wait-free containers and algorithms.
|
This class is used to maintain the list of hazard pointed objects. More...
#include <hazard_pointer.h>
Public Types | |
enum | SlotID : size_t { SlotID::SHORTUSE = 0, SlotID::SHORTUSE2, SlotID::PROG_ASSUR, SlotID::END } |
Public Member Functions | |
HazardPointer (int num_threads) | |
~HazardPointer () | |
void | watch (SlotID slot, void *value) |
This function takes a SlotID and stores the specified value into that the threads alloted slot for that id in the hazard pointer watch list. More... | |
void | clear_watch (SlotID slot) |
This function takes a SlotID and stores null into that the threads alloted slot for that id in the hazard pointer watch list. More... | |
bool | contains (void *value) |
This function returns true of the specified value is being watched. More... | |
DISALLOW_COPY_AND_ASSIGN (HazardPointer) | |
Static Public Member Functions | |
static bool | watch (SlotID slot_id, Element *elem, std::atomic< void * > *address, void *expected, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to achieve a hazard pointer watch on the the based descr. More... | |
static bool | watch (SlotID slot_id, void *value, std::atomic< void * > *address, void *expected, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to achieve a hazard pointer watch on a memory address. More... | |
static void | unwatch (SlotID slot_id, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to remove the hazard pointer watch. More... | |
static void | unwatch (SlotID slot_id, Element *descr, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to remove the hazard pointer watch. More... | |
static bool | is_watched (Element *descr, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to determine if a hazard pointer watch exists on a passed value. More... | |
static bool | is_watched (void *value, HazardPointer *const hazard_pointer=tervel::tl_thread_info->get_hazard_pointer()) |
This method is used to determine if a hazard pointer watch exists on a passed value. More... | |
Public Attributes | |
util::memory::hp::ListManager | hp_list_manager_ |
Private Member Functions | |
size_t | get_slot (SlotID id) |
This function calculates a the position of a threads slot for the specified SlotID. More... | |
Private Attributes | |
std::unique_ptr< std::atomic< void * >[]> | watches_ |
const size_t | num_slots_ |
This class is used to maintain the list of hazard pointed objects.
Any value can be written into a slot, however we provide special implementation for Elements, in that we call their on_* functions. This allows for more expressive operations to be performed.
If an individual thread requires more than one element to be hazard pointer protected at a single instance, then SlotIDs should be added.
|
strong |
|
explicit |
tervel::util::memory::hp::HazardPointer::~HazardPointer | ( | ) |
|
inline |
This function takes a SlotID and stores null into that the threads alloted slot for that id in the hazard pointer watch list.
slot | The id of the slot to watch. |
|
inline |
This function returns true of the specified value is being watched.
value | The value to check. |
tervel::util::memory::hp::HazardPointer::DISALLOW_COPY_AND_ASSIGN | ( | HazardPointer | ) |
|
inlineprivate |
This function calculates a the position of a threads slot for the specified SlotID.
slot | The slot id to get the position of |
|
static |
This method is used to determine if a hazard pointer watch exists on a passed value.
If a descr is passed then it will internally call descr->on_is_watched.
descr | to call on_is_watched on. |
|
static |
This method is used to determine if a hazard pointer watch exists on a passed value.
If a descr is passed then it will internally call descr->on_is_watched.
value | to check if watch |
|
static |
This method is used to remove the hazard pointer watch.
If a descr is passed then it will internally call descr->on_unwatch.
slot | the slot to remove the watch |
|
static |
This method is used to remove the hazard pointer watch.
If a descr is passed then it will internally call descr->on_unwatch.
slot | the slot to remove the watch |
descr | to call on_unwatch on. |
|
static |
This method is used to achieve a hazard pointer watch on the the based descr.
Internally it will call the descriptors on_watch function.
If after writing descr the object is still at the address (indicated by *a == value), it will call on_watch. If that returns true then it will return true. Otherwise it removes the hazard pointer watch and returns false
slot | The position to place the descr value in the watch table. |
descr | The descr that is to be watched. |
address | The address to check |
expected | The value which is to be expected at the address |
|
static |
This method is used to achieve a hazard pointer watch on a memory address.
If after writing the value, it is still at the address (indicated by *a == value), will return true. Otherwise it removes the hazard pointer watch and returns false
slot | The position to place the value in the watch table. |
value | The value that is to be watched. |
address | The address to check |
expected | The value which is to be expected at the address |
|
inline |
This function takes a SlotID and stores the specified value into that the threads alloted slot for that id in the hazard pointer watch list.
slot | The id of the slot to watch. |
value | The value to watch |
util::memory::hp::ListManager tervel::util::memory::hp::HazardPointer::hp_list_manager_ |
|
private |
|
private |