|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.tools.concurrent.InMemoryLockingStorage<K,V>
K - the key type.V - the object type.@ThreadSafe public final class InMemoryLockingStorage<K,V>
This implementation uses a simple and efficient in-memory object storage.
| Constructor Summary | |
|---|---|
InMemoryLockingStorage(IValueProducer<? super K,? extends V> producer)
Creates a new locking storage. |
|
| 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. |
List<V> |
values()
Returns a snapshot of all values currently stored in the storage. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InMemoryLockingStorage(IValueProducer<? super K,? extends V> producer)
producer - produces instances of objects which will be available as values.| Method Detail |
|---|
public V lockAndGet(K key)
ILockingStorage
lockAndGet in interface ILockingStorage<K,V>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.
public void unlock(K key)
ILockingStorage
unlock in interface ILockingStorage<K,V>key - the key to unlock, must not be null.public void unlockAndRemove(K key)
ILockingStorage
unlockAndRemove in interface ILockingStorage<K,V>key - the key, must not be null.public List<V> values()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||