, 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.
Method Summary |
Object |
runOperation(Object key,
edu.emory.mathcs.backport.java.util.concurrent.Callable operation)
The operation will be keyed on the name . |
runOperation
Object runOperation(Object key,
edu.emory.mathcs.backport.java.util.concurrent.Callable operation)
throws edu.emory.mathcs.backport.java.util.concurrent.ExecutionException
- The operation will be keyed on the name .
- Parameters:
key
- the key, like any map key this should be an immutable object that correctly implements
#hashCode()
and #equals(Object)
operation
- is the operation to execute whose result will be accessible to any concurrent callers with the same
key.
- Returns:
- result of the operation
- Throws:
edu.emory.mathcs.backport.java.util.concurrent.ExecutionException
- if the callable generated a checked exception, otherwise a runtime exception or error will be thrown
Copyright © 2002-2008 Atlassian. All Rights Reserved.