p->tail=realptr;
}
+static inline void* dqPopTopSelf(deque *p) {
+ int tryagain=1;
+ while(1) {
+ dequeItem *ptr=p->head;
+ dequeItem *realptr=(dequeItem *) EXTRACTPTR((INTPTR)ptr);
+ dequeItem *next=realptr->next;
+ //remove if we can..steal work no matter what
+ if (likely(next!=NULL)) {
+ if (((dequeItem *)CAS(&(p->head),(INTPTR)ptr, (INTPTR)next))!=ptr)
+ return DQ_POP_EMPTY;
+ void * item=NULL;
+ item=(void *)LOCKXCHG((unsigned INTPTR*) &(realptr->work), (unsigned INTPTR) item);
+ realptr->next=NULL;
+ BARRIER();
+ tagpoolfreeinto(&p->objret,ptr, realptr);
+ if (item==NULL&&tryagain) {
+ tryagain=0;
+ continue;
+ }
+ return item;
+ } else {
+ void * item=NULL;
+ if (realptr->work!=NULL)
+ item=(void *) LOCKXCHG((unsigned INTPTR*) &(realptr->work), (unsigned INTPTR) item);
+ return item;
+ }
+ }
+}
+
static inline void* dqPopTop(deque *p) {
dequeItem *ptr=p->head;
dequeItem *realptr=(dequeItem *) EXTRACTPTR((INTPTR)ptr);
}
}
-#define dqPopBottom dqPopTop
+#define dqPopBottom dqPopTopSelf
#endif // ___MEMPOOL_H__