25 bool complete(WFVector *vec,
int pos);
28 bool watch(
void *p, ArrayElement *a){
30 rc_count.fetch_add(1);
33 rc_count.fetch_add(-1);
39 controlOp->rc_count.fetch_add(1);
41 rc_count.fetch_add(-1);
42 controlOp->rc_count.fetch_add(-1);
51 rc_count.fetch_add(-1);
54 controlOp->rc_count.fetch_add(-1);
58 return (rc_count.load() !=0);
74 assert(type == dt_pushBack);
76 ArrayElement *pA=vec->getSpot(pos);
77 ArrayElement *pB=vec->getSpot(pos-1);
79 long spos=this->pos.load();
80 while (this->pos.load() == -1) {
82 if (fcount++ == MAX_FAILURES){
87 this->pos.compare_exchange_strong(spos, -2);
91 void *expected=pB->load();
93 if (Helper::isHelper(expected)) {
94 Helper *tHelper=Helper::unmark(expected);
96 if (!tHelper->watch(expected, pB)) {
99 bool helpRes = Helper::remove(vec, pos-1, expected);
102 if (!helpRes && rDepth>0) {
110 assert(!Helper::isHelper(expected));
111 if (expected == NOT_VALUE) {
112 this->pos.compare_exchange_strong(spos, -2);
115 this->pos.compare_exchange_strong(spos, pos);
120 spos=this->pos.load();
125 void *expected=Helper::mark(
this);
128 pA->compare_exchange_strong(expected, NOT_VALUE);
131 pA->compare_exchange_strong(expected,
value);
133 else if (op->assoc.compare_exchange_strong(temp,
this) || temp==
this){
134 pA->compare_exchange_strong(expected,
value);
137 pA->compare_exchange_strong(expected, NOT_VALUE);
Definition: push_helper.h:2
bool watch(void *p, ArrayElement *a)
Definition: push_helper.h:28
bool isWatched()
Definition: push_helper.h:57
void unwatch()
Definition: push_helper.h:50
bool complete(WFVector *vec, int pos)
Definition: push_helper.h:73
PushHelper(void *v, PushOp *op)
Definition: push_helper.h:19
PushHelper(void *v)
Definition: push_helper.h:15
PushOp * controlOp
Definition: push_helper.h:6
void * value
Definition: push_helper.h:4
bool tryFree()
Definition: push_helper.h:144
void init(void *v, PushOp *op)
Definition: push_helper.h:7
std::atomic< long > pos
Definition: push_helper.h:5
void * readThrough()
Definition: push_helper.h:61