25 #ifndef __TERVEL_CONTAINERS_WF_VECTOR_PUSHWRA_OP_H
26 #define __TERVEL_CONTAINERS_WF_VECTOR_PUSHWRA_OP_H
36 #include <tervel/containers/wf/vector/vector.hpp>
39 namespace containers {
56 assert(temp !=
nullptr);
67 size_t placed_pos =
vec_->size();
68 std::atomic<T> *spot =
vec_->internal_array.get_spot(placed_pos);
69 T current = spot->load();
71 while (
helper_.load() ==
nullptr) {
72 if (current == Vector<T>::c_not_value_) {
75 if (!spot->compare_exchange_strong(current, help_t)) {
78 helper->
complete(reinterpret_cast<void *>(help_t),
79 reinterpret_cast< std::atomic<void *> *
>(spot));
81 assert(
helper_.load() == helper);
83 }
else if (
vec_->internal_array.is_descriptor(current, spot)) {
87 spot =
vec_->internal_array.get_spot(placed_pos);
88 current = spot->load();
98 assert(temp !=
nullptr);
106 std::atomic<PushWRAOpHelper<T> *>
helper_ {
nullptr};
127 if (
op_->helper_.load() ==
nullptr) {
129 }
else if (
op_->helper_.load() ==
this) {
132 assert(
op_->helper_.load() !=
nullptr);
139 bool res =
op_->helper_.compare_exchange_strong(temp_null,
this);
140 if (res || temp_null ==
this) {
141 assert(
op_->helper_.load() ==
this);
150 void *
complete(
void *value, std::atomic<void *> *address) {
151 std::atomic<T> * spot =
reinterpret_cast<std::atomic<T> *
>(address);
154 assert(reinterpret_cast<T>(value) == new_current);
156 if (spot->compare_exchange_strong(new_current,
op_->new_val_)) {
157 new_current =
op_->new_val_;
166 return reinterpret_cast<void *
>(new_current);
171 return reinterpret_cast<void *
>(
op_->new_val_);
183 bool on_watch(std::atomic<void *> *address,
void * value) {
186 t_SlotID::SHORTUSE,
op_, address, value);
206 #endif // __TERVEL_CONTAINERS_WF_VECTOR_PUSHWRA_OP_H
DescrType * get_descriptor(Args &&...args)
Constructs and returns a descriptor.
Definition: descriptor_util.h:50
virtual void * get_logical_value()=0
This method is implemented by each sub class.
void help_complete()
Implementations of this function that upon its return the operation described in the OpRecord has bee...
Definition: pushbackwra_op.h:60
uint64_t idx()
Definition: pushbackwra_op.h:122
~PushWRAOp()
Definition: pushbackwra_op.h:54
__thread void * tl_control_word
PushWRAOp(Vector< T > *vec, T val)
Definition: pushbackwra_op.h:50
uint64_t idx()
Definition: pushback_op.h:311
void * mark_first(tervel::util::Descriptor *descr)
This returns the passed reference with its least signifcant bit set to 1.
Definition: descriptor_util.h:157
void free_descriptor(tervel::util::Descriptor *descr, bool dont_check=false)
Once a user is done with a descriptor, they should free it with this method.
Definition: descriptor_util.h:65
TODO(steven):
Definition: mcas.h:36
std::atomic< PushWRAOpHelper< T > * > helper_
Definition: pushbackwra_op.h:106
Definition: pushbackwra_op.h:48
Definition: pushbackwra_op.h:44
This defines the Descriptor class, this class is designed to be extend and be used in conjunction wit...
Definition: descriptor.h:60
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 ...
bool result()
Definition: pushbackwra_op.h:126
This class is used to create Operation Records.
Definition: progress_assurance.h:52
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: pushbackwra_op.h:150
uint64_t idx_
Definition: pushbackwra_op.h:197
uint64_t result()
Definition: pushbackwra_op.h:96
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: pushbackwra_op.h:170
PushWRAOpHelper(PushWRAOp< T > *op)
Definition: pushbackwra_op.h:114
bool on_watch(std::atomic< void * > *address, void *value)
This method is optional to implement for each sub class.
Definition: pushbackwra_op.h:183
Vector< T > * vec_
Definition: pushbackwra_op.h:104
Definition: pushback_op.h:44
T new_val_
Definition: pushbackwra_op.h:105
void set_idx(uint64_t i)
Definition: pushbackwra_op.h:118
bool associate()
Definition: pushbackwra_op.h:137
PushWRAOp< T > * op_
Definition: pushbackwra_op.h:196
SlotID
Definition: hazard_pointer.h:58