Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.emory.mathcs.util.remote.locks
Interface RemoteLock

All Superinterfaces:
  java.rmi.Remote

All Known Implementing Classes:
  AbstractPollingLock, ReentrantDistributedLock, RemoteEisMcGLock

public interface RemoteLock
extends java.rmi.Remote

Interface mirroring the Lock interface in java.util.concurrent but allowing for RemoteExceptions since an implementation will involve network communication. Semantics of equals: two remote locks should be considered equal w.r.t. the equals() method iff they represent the same remote lock, i.e. method calls on each of them must perform the same actions. In particular, it must be possible to call lock() on one of the objects and successful unlock() on the other.

Author:
  Dirk Gorissen , Dawid Kurzyniec

Method Summary
`void` | `lock()` Acquires the remote lock.
`void` | `lockInterruptibly()` Acquires the remote lock unless the current thread is interrupted.
`RemoteCondition` | `newCondition()` Returns a new Condition instance that is bound to this `RemoteLock` instance.
`boolean` | `tryLock()` Acquires the remote lock only if it is free at the time of invocation.
`boolean` | `tryLock(long time, TimeUnit unit)` Acquires the remote lock if it is free within the given waiting time and the current thread has not been interrupted.
`void` | `unlock()` Releases the remote lock.

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.

  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:
  - The lock is acquired by the current thread; or
  - Some other thread interrupts the current thread, and interruption of lock acquisition is supported.

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

### tryLock

    public boolean tryLock()
                    throws java.rmi.RemoteException

  Acquires the remote lock only if it is free at the time of invocation. If the lock is not available then this method will return immediately with the value `false`.

  Returns:
    `true` if the lock was acquired and `false` otherwise.
  Throws:
    `java.rmi.RemoteException` - if a communication error occurs

### tryLock

    public boolean tryLock(long time,
                           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:
  - 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

  Parameters:
    `time` - 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.lang.InterruptedException` - if the current thread is interrupted while acquiring the lock (and interruption of lock acquisition is supported).
    `java.rmi.RemoteException` - if a communication error occurs

### unlock

    public void unlock()
                throws java.rmi.RemoteException

  Releases the remote lock.

  Throws:
    `java.rmi.RemoteException` - if a communication error occurs

### newCondition

    public RemoteCondition newCondition()
                                 throws java.rmi.RemoteException

  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.

  Returns:
    A new Condition instance for this `RemoteLock` instance.
  Throws:
    `java.rmi.RemoteException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD