com.ideo.sweetdev.core.util
Class LockManager

java.lang.Object
  extended bycom.ideo.sweetdev.core.util.LockManager

public class LockManager
extends java.lang.Object

Utility class that manager multi-Thread access on readable/writtable resource.

 

Field Summary
static long MAXWAITING_LCKACCES
          max time waiting for lock access
static long MAXWAITING_READING
          max time waiting for reading
static long MAXWAITING_UPDATING
          max time waiting for updating
 
Constructor Summary
LockManager()
          Creates a new LockManager object.
LockManager(long _waitingForReading, long _waitingForUpdating)
          Creates a new LockManager object.
 
Method Summary
 void getReadAccessLock()
          Try to get a reading access right.
 long getWaitingForReadingTime()
          get time wainting for reading
 long getWaitingForUpdatingTime()
          get time waiting for updating
 void notifyAllWaitingThreads()
          Wake up every threads waiting for any access.
 void notifyReaders()
          Wake up every threads waiting for reading access.
 void notifyUpdaters()
          Wake up every threads waiting for updating access.
 void releaseReadAccessLock()
          Release reading access right.
 void releaseWriteAccessLock()
          release the write access lock
 void releaseWriteAccessLock(int _lockCounter)
          Release writting access right.
 void releaseWriteAccessLockAll()
          release all the write access locks
 void setWriteAccessLock()
          Set a writting access right.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXWAITING_READING

public static final long MAXWAITING_READING
max time waiting for reading

See Also:
Constant Field Values

MAXWAITING_UPDATING

public static final long MAXWAITING_UPDATING
max time waiting for updating

See Also:
Constant Field Values

MAXWAITING_LCKACCES

public static final long MAXWAITING_LCKACCES
max time waiting for lock access

See Also:
Constant Field Values
Constructor Detail

LockManager

public LockManager()
Creates a new LockManager object.


LockManager

public LockManager(long _waitingForReading,
                   long _waitingForUpdating)
Creates a new LockManager object.

Parameters:
_waitingForReading - time wainting for reading
_waitingForUpdating - time wainting for updating
Method Detail

getWaitingForReadingTime

public long getWaitingForReadingTime()
get time wainting for reading

Returns:
time wainting for reading

getWaitingForUpdatingTime

public long getWaitingForUpdatingTime()
get time waiting for updating

Returns:
time wainting for updating

getReadAccessLock

public void getReadAccessLock()
                       throws TechnicalException
Try to get a reading access right. The lock could be done only when no writting access exists.

Throws:
TechnicalException - te

setWriteAccessLock

public void setWriteAccessLock()
                        throws TechnicalException
Set a writting access right. The lock could be done only when every reading access is over.

Throws:
TechnicalException - te

releaseWriteAccessLock

public void releaseWriteAccessLock(int _lockCounter)
Release writting access right.

Parameters:
_lockCounter - int

releaseWriteAccessLock

public void releaseWriteAccessLock()
release the write access lock


releaseWriteAccessLockAll

public void releaseWriteAccessLockAll()
release all the write access locks


releaseReadAccessLock

public void releaseReadAccessLock()
Release reading access right.


notifyReaders

public void notifyReaders()
Wake up every threads waiting for reading access.


notifyUpdaters

public void notifyUpdaters()
Wake up every threads waiting for updating access.


notifyAllWaitingThreads

public void notifyAllWaitingThreads()
Wake up every threads waiting for any access.