org.gcube.common.core.state
Class GCUBEReadWriteLock.GCUBEWriteLock

java.lang.Object
  extended by java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock
      extended by org.gcube.common.core.state.GCUBEReadWriteLock.GCUBEWriteLock
All Implemented Interfaces:
Serializable, Lock
Enclosing class:
GCUBEReadWriteLock

public static class GCUBEReadWriteLock.GCUBEWriteLock
extends ReentrantReadWriteLock.WriteLock

An extension of ReentrantReadWriteLock.WriteLock that supports preemptive requests and acquisitions.

Author:
Fabio Simeoni (University of Strathclyde)
See Also:
Serialized Form

Method Summary
 void cancelPreemptive()
          Indicates failure of the preemptive thread.
 void lock()
          Deprecated. use lockInterruptibly() instead.
 void lockInterruptibly()
          
 void lockPreemptively()
          Acquires the lock preemptively.
 boolean tryLock()
          Extends the semantics of Lock.tryLock() to cater for lock preemption.
 boolean tryLock(long timeout, TimeUnit unit)
          
 void unlock()
          Extends unlock() to interrupt writer and reader threads in queue for the lock when invoked by the preemptive thread.
 
Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock
getHoldCount, isHeldByCurrentThread, newCondition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

lock

public void lock()
          throws org.gcube.common.core.state.GCUBEReadWriteLock.LockPreemptedException
Deprecated. use lockInterruptibly() instead.

Forces interruptibility on the standard semantics of Lock.lock() to cater for lock preemption.

Specified by:
lock in interface Lock
Overrides:
lock in class ReentrantReadWriteLock.WriteLock
Throws:
LockPreemptedException - if the lock is preempted.
org.gcube.common.core.state.GCUBEReadWriteLock.LockPreemptedException

tryLock

public boolean tryLock()
Extends the semantics of Lock.tryLock() to cater for lock preemption.

Specified by:
tryLock in interface Lock
Overrides:
tryLock in class ReentrantReadWriteLock.WriteLock
Returns:
false if the lock is already held by another thread or has been preempted.

lockInterruptibly

public void lockInterruptibly()
                       throws InterruptedException

Specified by:
lockInterruptibly in interface Lock
Overrides:
lockInterruptibly in class ReentrantReadWriteLock.WriteLock
Throws:
InterruptedException

lockPreemptively

public void lockPreemptively()
                      throws InterruptedException
Acquires the lock preemptively.

Throws:
LockPreemptedException - if the lock is preempted.
InterruptedException

tryLock

public boolean tryLock(long timeout,
                       TimeUnit unit)
                throws InterruptedException

Specified by:
tryLock in interface Lock
Overrides:
tryLock in class ReentrantReadWriteLock.WriteLock
Throws:
InterruptedException

unlock

public void unlock()
Extends unlock() to interrupt writer and reader threads in queue for the lock when invoked by the preemptive thread.

Specified by:
unlock in interface Lock
Overrides:
unlock in class ReentrantReadWriteLock.WriteLock

cancelPreemptive

public void cancelPreemptive()
                      throws IllegalMonitorStateException
Indicates failure of the preemptive thread.

Throws:
IllegalMonitorStateException - if the calling thread is not the preemptive thread or it is the preemptive thread but it has already released the lock.


Copyright © 2012. All Rights Reserved.