Ejemplo n.º 1
0
 /**
  * Tries to match node s to this node, if so, waking up thread. Fulfillers call tryMatch to
  * identify their waiters. Waiters block until they have been matched.
  *
  * @param s the node to match
  * @return true if successfully matched to s
  */
 boolean tryMatch(SNode s) {
   if (match == null && UNSAFE.compareAndSwapObject(this, matchOffset, null, s)) {
     Thread w = waiter;
     if (w != null) { // waiters need at most one unpark
       waiter = null;
       LockSupport.unpark(w);
     }
     return true;
   }
   return match == s;
 }
Ejemplo n.º 2
0
 /** Tries to CAS cleanMe slot. */
 boolean casCleanMe(QNode cmp, QNode val) {
   return cleanMe == cmp && UNSAFE.compareAndSwapObject(this, cleanMeOffset, cmp, val);
 }
Ejemplo n.º 3
0
 /** Tries to cas nt as new tail. */
 void advanceTail(QNode t, QNode nt) {
   if (tail == t) UNSAFE.compareAndSwapObject(this, tailOffset, t, nt);
 }
Ejemplo n.º 4
0
 /**
  * Tries to cas nh as new head; if successful, unlink old head's next node to avoid garbage
  * retention.
  */
 void advanceHead(QNode h, QNode nh) {
   if (h == head && UNSAFE.compareAndSwapObject(this, headOffset, h, nh))
     h.next = h; // forget old next
 }
Ejemplo n.º 5
0
 /** Tries to cancel by CAS'ing ref to this as item. */
 void tryCancel(Object cmp) {
   UNSAFE.compareAndSwapObject(this, itemOffset, cmp, this);
 }
Ejemplo n.º 6
0
 boolean casItem(Object cmp, Object val) {
   return item == cmp && UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val);
 }
Ejemplo n.º 7
0
 boolean casNext(QNode cmp, QNode val) {
   return next == cmp && UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
 }
Ejemplo n.º 8
0
 boolean casHead(SNode h, SNode nh) {
   return h == head && UNSAFE.compareAndSwapObject(this, headOffset, h, nh);
 }
Ejemplo n.º 9
0
 /** Tries to cancel a wait by matching node to itself. */
 void tryCancel() {
   UNSAFE.compareAndSwapObject(this, matchOffset, null, this);
 }
Ejemplo n.º 10
0
 boolean casNext(SNode cmp, SNode val) {
   return cmp == next && UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
 }