|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.concurrent.locks.ReentrantReadWriteLock
org.gcube.common.core.state.GCUBEReadWriteLock
public class GCUBEReadWriteLock
An extension of ReentrantReadWriteLock that allows preemptive acquisition of write locks.
A thread acquires the write lock preemptively (cf. GCUBEReadWriteLock.GCUBEWriteLock.lockPreemptively()) if its actions
preempt those of other threads that synchronise with it (e.g. removal of guarded state).
When the preemptive thread releases the write lock, threads that were waiting for it or will request it in the future
are immediately interrupted, unless the preemptive thread declares its own failure (cf. GCUBEReadWriteLock.GCUBEWriteLock.cancelPreemptive()).
The possibility of lock preemption implies that all locking operations are interruptible in principle.
Accordingly, GCUBEReadWriteLock.GCUBEWriteLock.lock() and GCUBEReadWriteLock.GCUBEReadLock.lock() are deprecated in favour of
GCUBEReadWriteLock.GCUBEWriteLock.lockInterruptibly() and GCUBEReadWriteLock.GCUBEReadLock.lockInterruptibly(). If used, they may throw
a LockPreemptedException.
| Nested Class Summary | |
|---|---|
static class |
GCUBEReadWriteLock.GCUBEReadLock
An extension of ReentrantReadWriteLock.WriteLock that supports
preemptive requests and acquisitions. |
static class |
GCUBEReadWriteLock.GCUBEWriteLock
An extension of ReentrantReadWriteLock.WriteLock that supports
preemptive requests and acquisitions. |
| Nested classes/interfaces inherited from class java.util.concurrent.locks.ReentrantReadWriteLock |
|---|
ReentrantReadWriteLock.ReadLock, ReentrantReadWriteLock.WriteLock |
| Field Summary | |
|---|---|
protected GCUBELog |
logger
Class logger. |
protected boolean |
preempted
Indicates completion of preemptive task. |
protected Thread |
preemptingThread
The thread that performs the preemptive task. |
| Constructor Summary | |
|---|---|
GCUBEReadWriteLock()
Creates an instance. |
|
GCUBEReadWriteLock(boolean fair)
Creates an instance with a given fairness policy. |
|
| Method Summary | |
|---|---|
protected boolean |
isPreempted()
Used internally to check whether the lock has been requested preemptively by a thread other than the current one. |
GCUBEReadWriteLock.GCUBEReadLock |
readLock()
|
void |
setLogger(GCUBELog logger)
Sets the resource's logger. |
GCUBEReadWriteLock.GCUBEWriteLock |
writeLock()
|
| Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock |
|---|
getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected GCUBELog logger
protected volatile Thread preemptingThread
protected volatile boolean preempted
| Constructor Detail |
|---|
public GCUBEReadWriteLock()
public GCUBEReadWriteLock(boolean fair)
fair - true if this lock should use a fair ordering policy| Method Detail |
|---|
public void setLogger(GCUBELog logger)
logger - the logger.public GCUBEReadWriteLock.GCUBEWriteLock writeLock()
writeLock in interface ReadWriteLockwriteLock in class ReentrantReadWriteLockpublic GCUBEReadWriteLock.GCUBEReadLock readLock()
readLock in interface ReadWriteLockreadLock in class ReentrantReadWriteLockprotected boolean isPreempted()
LockPreemptedException - if the lock has been requested preemptively by a thread other
than the current one.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||