org.garret.jipc
Interface JIPCMutex

All Superinterfaces:
JIPCPrimitive

public interface JIPCMutex
extends JIPCPrimitive

Synchronization object providing mutual exclusion. Mutex object supports nested locks, it means that if some session locks mutex N times, it should unlock it N time to release the mutex. Server is able to detect deadlock for mutexes.

Semantic of methods inherited from JIPCPrimitive:

waitFor
lock the mutex
reset
release the mutex (remove all locks). It is not required that session, invoking reset method be owner of the mutex


Field Summary
 
Fields inherited from interface org.garret.jipc.JIPCPrimitive
DEFAULT_RANK
 
Method Summary
 void lock()
          Lock mutex.
 boolean lock(long timeout)
          Try to lock the mutex with specified timeout.
 void priorityLock(int rank)
          Lock mutex.
 boolean priorityLock(int rank, long timeout)
          Try to lock the mutex with specified timeout.
 void unlock()
          Unlock mutex.
 
Methods inherited from interface org.garret.jipc.JIPCPrimitive
alreadyExists, close, getName, priorityWait, priorityWait, reset, waitFor, waitFor
 

Method Detail

lock

public void lock()
          throws JIPCException,
                 java.io.IOException
Lock mutex. Only one session can lock mutex each moment of time.

JIPCException
java.io.IOException

lock

public boolean lock(long timeout)
             throws JIPCException,
                    java.io.IOException
Try to lock the mutex with specified timeout. If lock can not be granted within specified time, request is failed.

Parameters:
timeout - time in milliseconds
Returns:
true if lock is granted, false of timeout is expired
JIPCException
java.io.IOException

priorityLock

public void priorityLock(int rank)
                  throws JIPCException,
                         java.io.IOException
Lock mutex. Only one session can lock mutex each moment of time.

Parameters:
rank - processes will be placed in wait queue in the order of increasing rank value and in the same order will be taken from the queue.
JIPCException
java.io.IOException

priorityLock

public boolean priorityLock(int rank,
                            long timeout)
                     throws JIPCException,
                            java.io.IOException
Try to lock the mutex with specified timeout. If lock can not be granted within specified time, request is failed.

Parameters:
rank - processes will be placed in wait queue in the order of increasing rank value and in the same order will be taken from the queue.
timeout - time in milliseconds
Returns:
true if lock is granted, false of timeout is expired
JIPCException
java.io.IOException

unlock

public void unlock()
            throws JIPCException,
                   java.io.IOException
Unlock mutex. This method release the mutex if number of unlocks is equal to number of locks

JIPCException
java.io.IOException