5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166e.extra; |
8 |
+ |
|
9 |
|
import java.util.concurrent.TimeUnit; |
10 |
|
import java.util.concurrent.TimeoutException; |
11 |
|
import java.util.concurrent.locks.Lock; |
41 |
|
* threads invoke short read-only methods much more frequently than |
42 |
|
* fully locked methods. |
43 |
|
* |
44 |
< |
* <p> Methods {@code awaitAvailability} and {@code getSequence} can |
44 |
> |
* <p>Methods {@code awaitAvailability} and {@code getSequence} can |
45 |
|
* be used together to define (partially) optimistic read-only methods |
46 |
|
* that are usually more efficient than ReadWriteLocks when they |
47 |
|
* apply. These methods should in general be structured as loops that |
110 |
|
private static final long serialVersionUID = 7373984872572414699L; |
111 |
|
|
112 |
|
static final class Sync extends AbstractQueuedLongSynchronizer { |
113 |
< |
static final long serialVersionUID = 2540673546047039555L; |
113 |
> |
private static final long serialVersionUID = 2540673546047039555L; |
114 |
|
|
115 |
|
/** |
116 |
|
* The number of times to spin in lock() and awaitAvailability(). |
258 |
|
|
259 |
|
/** |
260 |
|
* Creates an instance of {@code SequenceLock} that will retry |
261 |
< |
* attempts to acquire the lock at least the given number times |
261 |
> |
* attempts to acquire the lock at least the given number of times |
262 |
|
* before blocking. |
263 |
+ |
* |
264 |
+ |
* @param spins the number of times before blocking |
265 |
|
*/ |
266 |
|
public SequenceLock(int spins) { sync = new Sync(spins); } |
267 |
|
|
486 |
|
* the lock could be acquired |
487 |
|
* @throws InterruptedException if the current thread is interrupted |
488 |
|
* @throws NullPointerException if the time unit is null |
486 |
– |
* |
489 |
|
*/ |
490 |
|
public boolean tryLock(long timeout, TimeUnit unit) |
491 |
|
throws InterruptedException { |
511 |
|
* Throws UnsupportedOperationException. SequenceLocks |
512 |
|
* do not support Condition objects. |
513 |
|
* |
514 |
< |
* @throws UnsupportedOperationException |
514 |
> |
* @throws UnsupportedOperationException always |
515 |
|
*/ |
516 |
|
public Condition newCondition() { |
517 |
|
throw new UnsupportedOperationException(); |