80 |
|
* seems not to vary with number of CPUs (beyond 2) so is just |
81 |
|
* a constant. |
82 |
|
*/ |
83 |
< |
static final int maxTimedSpins = (NCPUS < 2)? 0 : 32; |
83 |
> |
static final int maxTimedSpins = (NCPUS < 2) ? 0 : 32; |
84 |
|
|
85 |
|
/** |
86 |
|
* The number of times to spin before blocking in untimed waits. |
123 |
|
nextUpdater.lazySet(this, this); |
124 |
|
} |
125 |
|
|
126 |
+ |
private static final long serialVersionUID = -3375979862319811754L; |
127 |
|
} |
128 |
|
|
129 |
|
/** |
135 |
|
// enough padding for 64bytes with 4byte refs |
136 |
|
Object p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pa, pb, pc, pd, pe; |
137 |
|
PaddedAtomicReference(T r) { super(r); } |
138 |
+ |
private static final long serialVersionUID = 8170090609809740854L; |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
/** head of the queue */ |
143 |
|
private transient final PaddedAtomicReference<QNode> head; |
144 |
+ |
|
145 |
|
/** tail of the queue */ |
146 |
|
private transient final PaddedAtomicReference<QNode> tail; |
147 |
|
|
205 |
|
Object x = first.get(); |
206 |
|
if (x != first && first.compareAndSet(x, e)) { |
207 |
|
LockSupport.unpark(first.waiter); |
208 |
< |
return isData? e : x; |
208 |
> |
return isData ? e : x; |
209 |
|
} |
210 |
|
} |
211 |
|
} |
243 |
|
Object x = first.get(); |
244 |
|
if (x != first && first.compareAndSet(x, e)) { |
245 |
|
LockSupport.unpark(first.waiter); |
246 |
< |
return isData? e : x; |
246 |
> |
return isData ? e : x; |
247 |
|
} |
248 |
|
} |
249 |
|
} |
266 |
|
if (mode == NOWAIT) |
267 |
|
return null; |
268 |
|
|
269 |
< |
long lastTime = (mode == TIMEOUT)? System.nanoTime() : 0; |
269 |
> |
long lastTime = (mode == TIMEOUT) ? System.nanoTime() : 0; |
270 |
|
Thread w = Thread.currentThread(); |
271 |
|
int spins = -1; // set to desired spin count below |
272 |
|
for (;;) { |
298 |
|
if (spins < 0) { |
299 |
|
QNode h = head.get(); // only spin if at head |
300 |
|
spins = ((h != null && h.next == s) ? |
301 |
< |
(mode == TIMEOUT? |
301 |
> |
((mode == TIMEOUT) ? |
302 |
|
maxTimedSpins : maxUntimedSpins) : 0); |
303 |
|
} |
304 |
|
if (spins > 0) |
489 |
|
public E take() throws InterruptedException { |
490 |
|
Object e = xfer(null, WAIT, 0); |
491 |
|
if (e != null) |
492 |
< |
return (E)e; |
492 |
> |
return (E) e; |
493 |
|
Thread.interrupted(); |
494 |
|
throw new InterruptedException(); |
495 |
|
} |
497 |
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException { |
498 |
|
Object e = xfer(null, TIMEOUT, unit.toNanos(timeout)); |
499 |
|
if (e != null || !Thread.interrupted()) |
500 |
< |
return (E)e; |
500 |
> |
return (E) e; |
501 |
|
throw new InterruptedException(); |
502 |
|
} |
503 |
|
|
504 |
|
public E poll() { |
505 |
< |
return (E)fulfill(null); |
505 |
> |
return (E) fulfill(null); |
506 |
|
} |
507 |
|
|
508 |
|
public int drainTo(Collection<? super E> c) { |
605 |
|
Object x = q.get(); |
606 |
|
QNode s = q.next; |
607 |
|
if (x != null && q != x && q != s) { |
608 |
< |
nextItem = (E)x; |
608 |
> |
nextItem = (E) x; |
609 |
|
snext = s; |
610 |
|
pnext = pred; |
611 |
|
next = q; |
652 |
|
if (!p.isData) |
653 |
|
return null; |
654 |
|
if (x != null) |
655 |
< |
return (E)x; |
655 |
> |
return (E) x; |
656 |
|
} |
657 |
|
} |
658 |
|
} |
775 |
|
s.defaultReadObject(); |
776 |
|
resetHeadAndTail(); |
777 |
|
for (;;) { |
778 |
< |
E item = (E)s.readObject(); |
778 |
> |
E item = (E) s.readObject(); |
779 |
|
if (item == null) |
780 |
|
break; |
781 |
|
else |