Main Page | Class Hierarchy | Class List | File List | Class Members

RIPCLock Class Reference

#include <RIPCLock.h>

Inheritance diagram for RIPCLock:

RIPCPrimitive List of all members.

Public Types

enum  RIPCPrimitiveType {
  RIPC_MUTEX, RIPC_EVENT, RIPC_SEMAPHORE, RIPC_BARRIER,
  RIPC_LOCK, RIPC_SHARED_MEMORY, RIPC_QUEUE
}
enum  RIPCRanks { DEFAULT_RANK = 0 }

Public Member Functions

void exclusiveLock ()
bool exclusiveLock (unsigned timeout)
void sharedLock ()
bool sharedLock (unsigned timeout)
virtual void priorityExclusiveLock (int rank)=0
virtual bool priorityExclusiveLock (int rank, unsigned timeout)=0
virtual void prioritySharedLock (int rank)=0
virtual bool prioritySharedLock (int rank, unsigned timeout)=0
virtual void unlock ()=0
RIPCPrimitiveType getType ()
char const * getTypeName ()
virtual char const * getName ()=0
virtual bool alreadyExists ()=0
void waitFor ()
bool waitFor (unsigned timeout)
virtual void priorityWait (int rank)=0
virtual bool priorityWait (int rank, unsigned timeout)=0
virtual void reset ()=0
virtual void close ()=0
virtual void * allocate (size_t size)
virtual void deallocate (void *obj, size_t size=0)

Static Public Member Functions

void deallocator (RIPCObject const &objDesc)

Detailed Description

Synchronization object for setting exlusive and shared locks. Locks are not nested - if session sets the same lock several time, all lock requests are succeed but single unlock request will unlock the object. It is possible to upgrade the lock: if session first lock object in shared mode and then in exclusive mode, lock will be upgraded to exclusive (Attention! upgrading locks can easily cause a deadlock if several session will try to upgrade their shared locks simultaneously).
It is not possible to downgrade the lock - locking of object in shared mode after granted exlusive lock has no effect.
Locks are granted in FIFO order - it means that if object is locked shared mode, then request for exclusive lock comes and is blocked and then if yet another request for shared lock is received, it will be also blocked and placed inqueue after excusive lock request. Server is able to detect deadlock for this primitive.

Semantic of methods inherited from RIPCPrimitive:

waitFor
set exlusive lock
reset
removes all locks (shared or exclusive). It is not required that session, invoking reset method be owner of this lock


Member Enumeration Documentation

enum RIPCPrimitive::RIPCPrimitiveType [inherited]
 

Primitive types


Member Function Documentation

virtual void* RIPCPrimitive::allocate size_t  size  )  [virtual, inherited]
 

Method for allocation memory for container elements (currently queue and shared memory). This method can be overriden by derived class* to provide custom allocation policy.

virtual bool RIPCPrimitive::alreadyExists  )  [pure virtual, inherited]
 

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

virtual void RIPCPrimitive::close  )  [pure virtual, inherited]
 

Close primitive. This method decrease access counter of the primitive and once it becomes zero, primitive is destroyed.

virtual void RIPCPrimitive::deallocate void *  obj,
size_t  size = 0
[virtual, inherited]
 

Method for deallocation memory for container elements (currently queue and shared memory). This method can be overriden by derived class to provide custom allocation policy.

bool RIPCLock::exclusiveLock unsigned  timeout  )  [inline]
 

Set exclusive lock with timeout. If lock can not be graned within specifed time, request is failed.

Parameters:
timeout time in milliseconds
Returns:
true if lock is granted, false of timeout is expired

void RIPCLock::exclusiveLock  )  [inline]
 

Set exlusive lock. No other session can set exclusive or shared lock.

virtual char const* RIPCPrimitive::getName  )  [pure virtual, inherited]
 

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

RIPCPrimitiveType RIPCLock::getType  )  [inline, virtual]
 

Get RIPC primitive type

Returns:
one of the constants from RIPCPrimitiveType enum

Implements RIPCPrimitive.

char const* RIPCPrimitive::getTypeName  )  [inherited]
 

Get RIPC primitive type name

Returns:
name of primitive type

virtual bool RIPCLock::priorityExclusiveLock int  rank,
unsigned  timeout
[pure virtual]
 

Set exclusive lock with timeout. If lock can not be graned within specifed time, request is failed.

Parameters:
timeout time in milliseconds
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.
Returns:
true if lock is granted, false of timeout is expired

virtual void RIPCLock::priorityExclusiveLock int  rank  )  [pure virtual]
 

Set exlusive lock. No other session can set exclusive or shared lock.

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.

virtual bool RIPCLock::prioritySharedLock int  rank,
unsigned  timeout
[pure virtual]
 

Set shared lock with timeout. If lock can not be graned within specifed time, request is failed.

Parameters:
timeout time in milliseconds
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.
Returns:
true if lock is granted, false of timeout is expired

virtual void RIPCLock::prioritySharedLock int  rank  )  [pure virtual]
 

Set shared lock. No other session can set exclusive lock but other shared locks are possible.

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.

virtual bool RIPCPrimitive::priorityWait int  rank,
unsigned  timeout
[pure virtual, inherited]
 

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

virtual void RIPCPrimitive::priorityWait int  rank  )  [pure virtual, inherited]
 

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.

virtual void RIPCPrimitive::reset  )  [pure virtual, inherited]
 

Reset primitive. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.

bool RIPCLock::sharedLock unsigned  timeout  )  [inline]
 

Set shared lock with timeout. If lock can not be graned within specifed time, request is failed.

Parameters:
timeout time in milliseconds
Returns:
true if lock is granted, false of timeout is expired

void RIPCLock::sharedLock  )  [inline]
 

Set shared lock. No other session can set exclusive lock but other shared locks are possible.

virtual void RIPCLock::unlock  )  [pure virtual]
 

Remove lock from the object

bool RIPCPrimitive::waitFor unsigned  timeout  )  [inline, inherited]
 

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.

Returns:
false if timeout is expired before primitive state is changed

void RIPCPrimitive::waitFor  )  [inline, inherited]
 

Wait until state of primitive is switched. Semantic of this method depends on particular primitive type and is explained in specification of each primitive.


The documentation for this class was generated from the following file:
Generated on Wed Nov 26 14:58:19 2003 for RIPC by doxygen 1.3.5