1 package cz.cuni.amis.pogamut.multi.utils.timekey; 2 3 import java.util.Set; 4 5 import cz.cuni.amis.pogamut.multi.utils.exception.TimeKeyNotLockedException; 6 7 public interface ITimeKeyManager { 8 9 /** 10 * Locks some "time" (or increment lock number if existing lock exists). 11 * @param time 12 */ 13 public void lock(long time); 14 15 /** 16 * True if the provided timeKey is explicitly locked (lock(key) was called). 17 * @param key 18 * @return 19 */ 20 public boolean isLocked(TimeKey key); 21 22 /** 23 * True if the provided timeKey is explicitly locked (lock(key) was called). 24 * @param time 25 * @return 26 */ 27 public boolean isLocked(long time); 28 29 /** 30 * Unlocks some "time". 31 * @param key 32 * @throws TimeKeyNotLockedException 33 */ 34 public void unlock(long key) throws TimeKeyNotLockedException; 35 36 /** 37 * Completely unlocks one time (regardless number of locks held). 38 * @param time 39 * @throws TimeKeyNotLockedException 40 */ 41 public void unlockAll(long time) throws TimeKeyNotLockedException; 42 43 /** 44 * Unlock all times. 45 */ 46 public void unlockAll(); 47 48 /** 49 * Returns an immutable collection of currently held timeKeys. 50 * @return 51 */ 52 public Set<Long> getHeldKeys(); 53 54 /** 55 * Returns an immutable collection of currently held timeKeys as string. 56 * @return 57 */ 58 public String getHeldKeysStr(); 59 60 }