25 #ifndef TERVEL_MCAS_MCAS_HELPER_H_
26 #define TERVEL_MCAS_MCAS_HELPER_H_
37 namespace algorithms {
74 bool on_watch(std::atomic<void *> *address,
void * value) {
77 t_SlotID::SHORTUSE,
mcas_op_, address, value);
84 if (curr_mch ==
nullptr) {
85 if (
cas_row_->helper_.compare_exchange_strong(curr_mch,
this)) {
92 assert(
cas_row_->helper_.load() == curr_mch);
94 if (curr_mch !=
this) {
98 address->compare_exchange_strong(value,
cas_row_->expected_value_);
109 assert(
cas_row_->helper_.load() !=
nullptr);
127 void *
complete(
void *value, std::atomic<void *> *address) {
132 this->
cas_row_->helper_.compare_exchange_strong(temp_null,
this);
134 bool success =
false;
135 if (temp_null ==
nullptr || temp_null ==
this) {
149 address->compare_exchange_strong(value,
150 reinterpret_cast<void *>(this->
cas_row_->new_value_));
153 address->compare_exchange_strong(value,
154 reinterpret_cast<void *>(this->
cas_row_->expected_value_));
157 return address->load();
173 return this->
cas_row_->expected_value_;
190 #endif // TERVEL_MCAS_MCAS_HELPER_H_
virtual void * get_logical_value()=0
This method is implemented by each sub class.
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.
This class is used to represent a one of the M CAS operations performed by an MCAS operation...
Definition: mcas_casrow.h:45
TODO(steven):
Definition: mcas.h:36
MCAS< T > * mcas_op_
Definition: mcas_helper.h:180
CasRow< T > * cas_row_
Definition: mcas_helper.h:178
bool on_watch(std::atomic< void * > *address, void *value)
This method is optional to implement for each sub class.
Definition: mcas_helper.h:74
bool is_watched(tervel::util::Descriptor *descr)
This method is used to determine if the passed descriptor is under rc protection. ...
Definition: descriptor_util.h:78
static bool recursive_return(bool change=false, bool value=false)
This defines the Descriptor class, this class is designed to be extend and be used in conjunction wit...
Definition: descriptor.h:60
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.
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.
virtual void * complete(void *current, std::atomic< void * > *address)=0
This method is implemented by each sub class and must guarantee that upon return that the descriptor ...
Definition: mcas_helper.h:42
void * complete(void *value, std::atomic< void * > *address)
This method is implemented by each sub class and must guarantee that upon return that the descriptor ...
Definition: mcas_helper.h:127
virtual bool on_watch(std::atomic< void * > *, void *)
This method is optional to implement for each sub class.
Definition: descriptor.h:99
void * get_logical_value()
This method is implemented by each sub class.
Definition: mcas_helper.h:168
This class is the MCAS operation's helper.
Definition: mcas_casrow.h:37
SlotID
Definition: hazard_pointer.h:58