org.garret.jipc
Interface JIPCPrimitive

All Known Subinterfaces:
JIPCBarrier, JIPCEvent, JIPCLock, JIPCMutex, JIPCQueue, JIPCSemaphore, JIPCSharedMemory

public interface JIPCPrimitive

Base class for all synchronizatin primitives. Semantic of waitFor and reset methods for particular primitives explained in the descripotion of these proimitives


Field Summary
static int DEFAULT_RANK
          Rank with which requsts will be queued if rank was not explicitely specified.
 
Method Summary
 boolean alreadyExists()
          Primitive returned by createXXX method already exists This method should be call immediatly after createXXX to check if new primitive was created or existed one was returned.
 void close()
          Close primitive.
 java.lang.String getName()
          Get primitive name.
 void priorityWait(int rank)
          Priority wait until state of primitive is switched.
 boolean priorityWait(int rank, long timeout)
          Priority wait until state of primitive is switched with timeout.
 void reset()
          Reset primitive.
 void waitFor()
          Wait until state of primitive is switched.
 boolean waitFor(long timeout)
          Wait until state of primitive is switched with timeout.
 

Field Detail

DEFAULT_RANK

public static final int DEFAULT_RANK
Rank with which requsts will be queued if rank was not explicitely specified.

See Also:
Constant Field Values
Method Detail

alreadyExists

public boolean alreadyExists()
Primitive returned by createXXX method already exists This method should be call immediatly after createXXX to check if new primitive was created or existed one was returned.

Returns:
true if createXXX method doesn't create new primitive

close

public void close()
           throws JIPCException,
                  java.io.IOException
Close primitive. This method decrease access counter of the primitive and once it becomes zero, primitive is destroyed.

JIPCException
java.io.IOException

getName

public java.lang.String getName()
Get primitive name. Name of the primitive is unique with primitives of the same type (events, semaphores,...). It is possible that, for example, event and mutex has the same name.

Returns:
primitive name

priorityWait

public void priorityWait(int rank)
                  throws JIPCException,
                         java.io.IOException
Priority wait until state of primitive is switched. Requests with the lowest rank value will be satisfied first. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

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

priorityWait

public boolean priorityWait(int rank,
                            long timeout)
                     throws JIPCException,
                            java.io.IOException
Priority wait until state of primitive is switched with timeout. Requests with the lowest rank value will be satisfied first. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

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 - operation timeout in millisoconds
Returns:
false if timeout is expired before primitive state is changed
JIPCException
java.io.IOException

reset

public void reset()
           throws JIPCException,
                  java.io.IOException
Reset primitive. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

JIPCException
java.io.IOException

waitFor

public void waitFor()
             throws JIPCException,
                    java.io.IOException
Wait until state of primitive is switched. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

JIPCException
java.io.IOException

waitFor

public boolean waitFor(long timeout)
                throws JIPCException,
                       java.io.IOException
Wait until state of primitive is switched with timeout. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

Parameters:
timeout - operation timeout in millisoconds
Returns:
false if timeout is expired before primitive state is changed
JIPCException
java.io.IOException