edu.emory.mathcs.util.remote.locks
Class AbstractPollingLock

java.lang.Object
  extended byedu.emory.mathcs.util.remote.locks.AbstractPollingLock
All Implemented Interfaces:
java.rmi.Remote, RemoteLock

public abstract class AbstractPollingLock
extends java.lang.Object
implements RemoteLock

Author:
Dawid Kurzyniec

Constructor Summary
protected AbstractPollingLock()
           
protected AbstractPollingLock(float backoff, long initDelay, long maxDelay)
           
protected AbstractPollingLock(int retries, float backoff, long initDelay, long maxDelay)
           
 
Method Summary
 void lock()
          Acquires the remote lock. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.
 void lockInterruptibly()
          Acquires the remote lock unless the current thread is interrupted. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
  • The lock is acquired by the current thread; or
  • Some other thread interrupts the current thread, and interruption of lock acquisition is supported.
 RemoteCondition newCondition()
          Returns a new Condition instance that is bound to this RemoteLock instance.
 boolean tryLock(long timeout, TimeUnit unit)
          Acquires the remote lock if it is free within the given waiting time and the current thread has not been interrupted. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
  • The lock is acquired by the current thread; or
  • Some other thread interrupts the current thread, and interruption of lock acquisition is supported; or
  • The specified waiting time elapses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.emory.mathcs.util.remote.locks.RemoteLock
tryLock, unlock
 

Constructor Detail

AbstractPollingLock

protected AbstractPollingLock()

AbstractPollingLock

protected AbstractPollingLock(float backoff,
                              long initDelay,
                              long maxDelay)

AbstractPollingLock

protected AbstractPollingLock(int retries,
                              float backoff,
                              long initDelay,
                              long maxDelay)
Method Detail

lock

public void lock()
          throws java.rmi.RemoteException
Acquires the remote lock. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Specified by:
lock in interface RemoteLock
Throws:
java.rmi.RemoteException - if a communication error occurs

lockInterruptibly

public void lockInterruptibly()
                       throws java.lang.InterruptedException,
                              java.rmi.RemoteException
Acquires the remote lock unless the current thread is interrupted. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:

Specified by:
lockInterruptibly in interface RemoteLock
Throws:
java.rmi.RemoteException - if a communication error occurs
java.lang.InterruptedException - if the current thread is interrupted while acquiring the lock (and interruption of lock acquisition is supported).

tryLock

public boolean tryLock(long timeout,
                       TimeUnit unit)
                throws java.lang.InterruptedException,
                       java.rmi.RemoteException
Acquires the remote lock if it is free within the given waiting time and the current thread has not been interrupted. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:

Specified by:
tryLock in interface RemoteLock
Parameters:
timeout - the maximum time to wait for the lock
unit - the time unit of the time argument.
Returns:
true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.
Throws:
java.rmi.RemoteException - if a communication error occurs
java.lang.InterruptedException - if the current thread is interrupted while acquiring the lock (and interruption of lock acquisition is supported).

newCondition

public RemoteCondition newCondition()
Description copied from interface: RemoteLock
Returns a new Condition instance that is bound to this RemoteLock instance. Before waiting on the condition the lock must be held by the current thread.

Specified by:
newCondition in interface RemoteLock
Returns:
A new Condition instance for this RemoteLock instance.