cz.cuni.amis.pogamut.multi.utils.timekey
Class TimeKeyManager

java.lang.Object
  extended by cz.cuni.amis.pogamut.multi.utils.timekey.TimeKeyManager

public class TimeKeyManager
extends java.lang.Object

Singleton class that manages timekey locks and unlocks,


Method Summary
static TimeKeyManager get()
          Get the singleton instance.
 java.util.Collection<java.lang.Long> getHeldKeys()
          Returns an immutable collection of currently held timeKeys.
 java.lang.String getHeldKeysStr()
          Returns an immutable collection of currently held timeKeys as string.
 boolean isLocked(long time)
          True if the provided timeKey is explicitly locked ( lock(key) was called)
 boolean isLocked(TimeKey key)
          True if the provided timeKey is explicitly locked ( lock(key) was called)
 void lock(long key)
           
 void unlock(long key)
           
 void unlockAll()
          Unlock all keys.
 void unlockAll(long key)
          Completely unlocks one key (regardles number of locks held).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHeldKeys

public java.util.Collection<java.lang.Long> getHeldKeys()
Returns an immutable collection of currently held timeKeys.

Returns:

getHeldKeysStr

public java.lang.String getHeldKeysStr()
Returns an immutable collection of currently held timeKeys as string.

Returns:

get

public static TimeKeyManager get()
Get the singleton instance.

Returns:

isLocked

public boolean isLocked(TimeKey key)
True if the provided timeKey is explicitly locked ( lock(key) was called)

Parameters:
key -
Returns:

isLocked

public boolean isLocked(long time)
True if the provided timeKey is explicitly locked ( lock(key) was called)

Parameters:
time -
Returns:

unlock

public void unlock(long key)
            throws TimeKeyNotLockedException
Throws:
TimeKeyNotLockedException

unlockAll

public void unlockAll(long key)
               throws TimeKeyNotLockedException
Completely unlocks one key (regardles number of locks held).

Parameters:
key -
Throws:
TimeKeyNotLockedException

lock

public void lock(long key)

unlockAll

public void unlockAll()
Unlock all keys.