26 |
|
* in method {@link #unlockWrite} to release the lock. Untimed and |
27 |
|
* timed versions of {@code tryWriteLock} are also provided. When |
28 |
|
* the lock is held in write mode, no read locks may be obtained, |
29 |
< |
* and all observer validations will fail. </li> |
29 |
> |
* and all optimistic read validations will fail. </li> |
30 |
|
* |
31 |
|
* <li><b>Reading.</b> Method {@link #readLock} possibly blocks |
32 |
|
* waiting for non-exclusive access, returning a stamp that can be |
87 |
|
* |
88 |
|
* <pre>{@code |
89 |
|
* class Point { |
90 |
< |
* private volatile double x, y; |
90 |
> |
* private double x, y; |
91 |
|
* private final StampedLock sl = new StampedLock(); |
92 |
|
* |
93 |
|
* void move(double deltaX, double deltaY) { // an exclusively locked method |
237 |
|
/** Maximum number of retries before blocking on acquisition */ |
238 |
|
private static final int SPINS = (NCPU > 1) ? 1 << 6 : 1; |
239 |
|
|
240 |
< |
/** Maximum number of retries before re-blocking on write lock */ |
240 |
> |
/** Maximum number of retries before re-blocking */ |
241 |
|
private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 12 : 1; |
242 |
|
|
243 |
|
/** The period for yielding when waiting for overflow spinlock */ |
1103 |
|
/** |
1104 |
|
* If node non-null, forces cancel status and unsplices from queue |
1105 |
|
* if possible, by traversing entire queue looking for cancelled |
1106 |
< |
* nodes, cleaning out all at head, but stopping upon first |
1107 |
< |
* encounter otherwise. |
1106 |
> |
* nodes. |
1107 |
|
*/ |
1108 |
|
private long cancelReader(RNode node, boolean interrupted) { |
1109 |
|
Thread w; |
1118 |
|
} |
1119 |
|
else { |
1120 |
|
U.compareAndSwapObject(pred, RNEXT, p, q); |
1121 |
< |
break; |
1121 |
> |
p = pred.next; |
1122 |
|
} |
1123 |
|
} |
1124 |
|
else { |