|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
K - the key type. The key must comply contract to act as a key in Java Map - for example, Object.equals(java.lang.Object)
and Object.hashCode() have to be implemented correctly.V - the object type.public interface ILockingStorage<K,V>
An object storage, allows thread locking and retrieving of objects stored under a key. Similar to a Map. The main difference
is that each entry is protected by a lock:
when a thread retrieves an object, the key is locked until the thread puts the object back into the storage. Other threads have to wait to retrieve the same key contents.
The storage must handle null values.
IValueProducer in their constructors.
Memory consistency effects: actions in a thread prior to unlocking a key in a storage happen-before actions subsequent to the locking of that key in the storage in another thread.
| Method Summary | |
|---|---|
V |
lockAndGet(K key)
Performs an atomic lock on given key and atomically retrieves a value stored under given ID. |
void |
unlock(K key)
Atomically unlocks a lock on given key. |
void |
unlockAndRemove(K key)
Atomically unlocks a lock with given key and deletes the value object stored under the key. |
| Method Detail |
|---|
V lockAndGet(K key)
key - the key, must not be null. The key must be suitable for insertion into a Map: for example, the Object.equals(java.lang.Object) and Object.hashCode() must be implemented correctly.
void unlock(K key)
key - the key to unlock, must not be null.
NullPointerException - if no such key was locked.
IllegalArgumentException - if no thread holds a lock for given key.void unlockAndRemove(K key)
key - the key, must not be null.
NullPointerException - if no such key was locked.
IllegalArgumentException - if no thread holds a lock for given key.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||