1 #ifndef __VECTOR_PUSH_OP_H_
2 #define __VECTOR_PUSH_OP_H_
7 std::atomic<PushHelper<T> *>
helper_{
nullptr};
8 std::atomic<size_t>
pos_{-1};
25 size_t pushed_pos = vector_->size();
33 if (fcount++ < util::ProgressAssurance::MAX_FAILURES) {
34 util::ProgressAssurance::make_announcement(
35 reinterpret_cast<tervel::util::OpRecord *>(op));
37 pushed_pos = op->result();
42 ArrayElement *spot=vec->getSpot(pushedPos);
43 void *expected= spot->load();
45 if( expected==NOT_VALUE){
48 if(spot->compare_exchange_strong(expected, value)){
53 spot=vec->getSpot(pushedPos);
57 assert(pushedPos >=1);
61 if(spot->compare_exchange_strong(expected, Helper::mark(ph)) ){
64 long res=ph->
pos.load();
76 else if(Helper::isHelper(expected)){
77 Helper *tHelper=Helper::unmark(expected);
78 if(!tHelper->watch(expected, spot)){
82 bool helpRes=Helper::remove(vec, pushedPos,expected );
87 vec->announceOp(
this);
88 long res= this->s_execute(vec);
102 size_t PushOp::s_execute(WFVector *vec){
104 controlWord=(std::atomic<void *> *)(&(assoc));
106 long pushedPos=vec->csize.load();
107 while(this->assoc.load() == NULL){
112 ArrayElement *spot=vec->getSpot(pushedPos);
113 void *expected= spot->load();
115 if( expected==NOT_VALUE){
118 if(spot->compare_exchange_strong(expected, Helper::mark(ph)) ){
134 else if(Helper::isHelper(expected)){
135 Helper *tHelper=Helper::unmark(expected);
136 if(!tHelper->watch(expected, spot)){
139 Helper::remove(vec, pushedPos, expected );
148 return this->assoc.load()->pos;
152 bool PushOp::tryFree(){
153 if(this->isWatched()){
169 #endif // __VECTOR_PUSH_OP_H_
__thread void * tl_control_word
std::atomic< size_t > pos_
Definition: push_op.h:8
Definition: push_helper.h:2
PushOp(Vector vector, T value)
Definition: push_op.h:11
size_t begin()
Definition: push_op.h:22
bool isWatched()
Definition: push_helper.h:57
bool complete(WFVector *vec, int pos)
Definition: push_helper.h:73
std::atomic< PushHelper< T > * > helper_
Definition: push_op.h:7
const Vector vector_ const T value_
Definition: push_op.h:10
std::atomic< long > pos
Definition: push_helper.h:5