java.util.concurrent.locks
Class ReentrantReadWriteLock.FairSync
java.lang.Object
java.util.concurrent.locks.AbstractQueuedSynchronizer
java.util.concurrent.locks.ReentrantReadWriteLock.Sync
java.util.concurrent.locks.ReentrantReadWriteLock.FairSync
- All Implemented Interfaces:
- Serializable
- Enclosing class:
- ReentrantReadWriteLock
static final class ReentrantReadWriteLock.FairSync
- extends ReentrantReadWriteLock.Sync
Fair version of Sync
|
Method Summary |
protected boolean |
tryAcquire(int acquires)
Attempts to acquire in exclusive mode. |
protected int |
tryAcquireShared(int acquires)
Attempts to acquire in shared mode. |
(package private) void |
wlock()
Perform write lock. |
| Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock.Sync |
getCount, getOwner, getReadLockCount, getWriteHoldCount, isHeldExclusively, isWriteLocked, newCondition, nonfairTryAcquire, nonfairTryAcquireShared, tryRelease, tryReleaseShared |
| Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer |
acquire, acquireInterruptibly, acquireQueued, acquireShared, acquireSharedInterruptibly, compareAndSetState, fullyRelease, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isOnSyncQueue, isQueued, owns, release, releaseShared, setState, toString, transferAfterCancelledWait, transferForSignal, tryAcquireNanos, tryAcquireSharedNanos |
ReentrantReadWriteLock.FairSync
ReentrantReadWriteLock.FairSync()
tryAcquire
protected final boolean tryAcquire(int acquires)
- Description copied from class:
AbstractQueuedSynchronizer
- Attempts to acquire in exclusive mode. This method should query
if the state of the object permits it to be acquired in the
exclusive mode, and if so to acquire it.
This method is always invoked by the thread performing
acquire. If this method reports failure, the acquire method
may queue the thread, if it is not already queued, until it is
signalled by a release from some other thread. This can be used
to implement method Lock.tryLock().
The default
implementation throws UnsupportedOperationException
- Overrides:
tryAcquire in class AbstractQueuedSynchronizer
- Parameters:
acquires - the acquire argument. This value
is always the one passed to an acquire method,
or is the value saved on entry to a condition wait.
The value is otherwise uninterpreted and can represent anything
you like.
- Returns:
- true if successful. Upon success, this object has been
acquired.
tryAcquireShared
protected final int tryAcquireShared(int acquires)
- Description copied from class:
AbstractQueuedSynchronizer
- Attempts to acquire in shared mode. This method should query if
the state of the object permits it to be acquired in the shared
mode, and if so to acquire it.
This method is always invoked by the thread performing
acquire. If this method reports failure, the acquire method
may queue the thread, if it is not already queued, until it is
signalled by a release from some other thread.
The default implementation throws UnsupportedOperationException
- Overrides:
tryAcquireShared in class AbstractQueuedSynchronizer
- Parameters:
acquires - the acquire argument. This value
is always the one passed to an acquire method,
or is the value saved on entry to a condition wait.
The value is otherwise uninterpreted and can represent anything
you like.
- Returns:
- a negative value on failure, zero on exclusive success,
and a positive value if non-exclusively successful, in which
case a subsequent waiting thread must check
availability. (Support for three different return values
enables this method to be used in contexts where acquires only
sometimes act exclusively.) Upon success, this object has been
acquired.
wlock
final void wlock()
- Description copied from class:
ReentrantReadWriteLock.Sync
- Perform write lock. Allows fast path in non-fair version.
- Specified by:
wlock in class ReentrantReadWriteLock.Sync
Please submit a feedback, bug or feature