@ThreadSafe
public interface ConcurrentOperationMap<K,R>
Callable, and keyed by an Object <K>,
such that the result of the Callable will be available to any concurrent
callers with the same Object key. The result of the Callable is discarded
after the operation has succeeded.
There is an assumption that the callers that are using this will submit the same Operations associated with the same keyed Object AND that the operations will be idempotent. This structure only ensures that if Concurrent operations with the same key are submitted that ONLY ONE of the operations will be executed. If the operations are not concurrent then both operations will be executed, hence the need for them to be idempotent.
Essentially, this is a Map whose elements expire very quickly. It is particularly useful for situations where you need to get or create the result, and you want to prevent concurrent creation of the result.
| Modifier and Type | Method and Description |
|---|---|
R |
runOperation(K key,
Callable<R> operation)
The operation <R> will be keyed on the name <K>.
|
R runOperation(K key, Callable<R> operation) throws ExecutionException
key - the key, like any map key this should be an immutable object
that correctly implements Object.hashCode() and
Object.equals(Object)operation - is the operation to execute whose result will be
accessible to any concurrent callers with the same key.ExecutionException - if the callable generated a
checked exception, otherwise a runtime exception or error will be thrownCopyright © 2024 Atlassian. All rights reserved.