Пример #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;
 }
Пример #2
0
 /** Tries to CAS cleanMe slot. */
 boolean casCleanMe(QNode cmp, QNode val) {
   return cleanMe == cmp && UNSAFE.compareAndSwapObject(this, cleanMeOffset, cmp, val);
 }
Пример #3
0
 /** Tries to cas nt as new tail. */
 void advanceTail(QNode t, QNode nt) {
   if (tail == t) UNSAFE.compareAndSwapObject(this, tailOffset, t, nt);
 }
Пример #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
 }
Пример #5
0
 /** Tries to cancel by CAS'ing ref to this as item. */
 void tryCancel(Object cmp) {
   UNSAFE.compareAndSwapObject(this, itemOffset, cmp, this);
 }
Пример #6
0
 boolean casItem(Object cmp, Object val) {
   return item == cmp && UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val);
 }
Пример #7
0
 boolean casNext(QNode cmp, QNode val) {
   return next == cmp && UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
 }
Пример #8
0
 boolean casHead(SNode h, SNode nh) {
   return h == head && UNSAFE.compareAndSwapObject(this, headOffset, h, nh);
 }
Пример #9
0
 /** Tries to cancel a wait by matching node to itself. */
 void tryCancel() {
   UNSAFE.compareAndSwapObject(this, matchOffset, null, this);
 }
Пример #10
0
 boolean casNext(SNode cmp, SNode val) {
   return cmp == next && UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
 }