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. |
202 |
|
Object x = first.get(); |
203 |
|
if (x != first && first.compareAndSet(x, e)) { |
204 |
|
LockSupport.unpark(first.waiter); |
205 |
< |
return isData? e : x; |
205 |
> |
return isData ? e : x; |
206 |
|
} |
207 |
|
} |
208 |
|
} |
240 |
|
Object x = first.get(); |
241 |
|
if (x != first && first.compareAndSet(x, e)) { |
242 |
|
LockSupport.unpark(first.waiter); |
243 |
< |
return isData? e : x; |
243 |
> |
return isData ? e : x; |
244 |
|
} |
245 |
|
} |
246 |
|
} |
263 |
|
if (mode == NOWAIT) |
264 |
|
return null; |
265 |
|
|
266 |
< |
long lastTime = (mode == TIMEOUT)? System.nanoTime() : 0; |
266 |
> |
long lastTime = (mode == TIMEOUT) ? System.nanoTime() : 0; |
267 |
|
Thread w = Thread.currentThread(); |
268 |
|
int spins = -1; // set to desired spin count below |
269 |
|
for (;;) { |
295 |
|
if (spins < 0) { |
296 |
|
QNode h = head.get(); // only spin if at head |
297 |
|
spins = ((h != null && h.next == s) ? |
298 |
< |
(mode == TIMEOUT? |
298 |
> |
((mode == TIMEOUT) ? |
299 |
|
maxTimedSpins : maxUntimedSpins) : 0); |
300 |
|
} |
301 |
|
if (spins > 0) |
486 |
|
public E take() throws InterruptedException { |
487 |
|
Object e = xfer(null, WAIT, 0); |
488 |
|
if (e != null) |
489 |
< |
return (E)e; |
489 |
> |
return (E) e; |
490 |
|
Thread.interrupted(); |
491 |
|
throw new InterruptedException(); |
492 |
|
} |
494 |
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException { |
495 |
|
Object e = xfer(null, TIMEOUT, unit.toNanos(timeout)); |
496 |
|
if (e != null || !Thread.interrupted()) |
497 |
< |
return (E)e; |
497 |
> |
return (E) e; |
498 |
|
throw new InterruptedException(); |
499 |
|
} |
500 |
|
|
501 |
|
public E poll() { |
502 |
< |
return (E)fulfill(null); |
502 |
> |
return (E) fulfill(null); |
503 |
|
} |
504 |
|
|
505 |
|
public int drainTo(Collection<? super E> c) { |
602 |
|
Object x = q.get(); |
603 |
|
QNode s = q.next; |
604 |
|
if (x != null && q != x && q != s) { |
605 |
< |
nextItem = (E)x; |
605 |
> |
nextItem = (E) x; |
606 |
|
snext = s; |
607 |
|
pnext = pred; |
608 |
|
next = q; |
649 |
|
if (!p.isData) |
650 |
|
return null; |
651 |
|
if (x != null) |
652 |
< |
return (E)x; |
652 |
> |
return (E) x; |
653 |
|
} |
654 |
|
} |
655 |
|
} |
772 |
|
s.defaultReadObject(); |
773 |
|
resetHeadAndTail(); |
774 |
|
for (;;) { |
775 |
< |
E item = (E)s.readObject(); |
775 |
> |
E item = (E) s.readObject(); |
776 |
|
if (item == null) |
777 |
|
break; |
778 |
|
else |