Class OpCache
java.lang.Object
VASSAL.tools.opcache.OpCache
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
<V> V
get
(OpCache.Key<V> key) Gets a value from the cache.<V> V
get
(OpCache.Key<V> key, OpObserver<V> obs) Gets a value from the cache, possibly asynchronously.<V> Future
<V> getFuture
(OpCache.Key<V> key, OpObserver<V> obs) Gets aFuture
from the cache.<V> V
getIfDone
(OpCache.Key<V> key) Gets a value from the cache, if it is already calculated.
-
Field Details
-
cache
-
-
Constructor Details
-
OpCache
public OpCache()
-
-
Method Details
-
get
Gets a value from the cache.- Parameters:
key
- theKey
for which to retrieve a value- Returns:
- the value associated with
key
-
get
public <V> V get(OpCache.Key<V> key, OpObserver<V> obs) throws CancellationException, InterruptedException, ExecutionException Gets a value from the cache, possibly asynchronously.- Parameters:
key
- theKey
for which to retrieve a valueobs
- theOpObserver
to notify when the value is available- Returns:
- the value associated with
key
- Throws:
CancellationException
- if the request is cancelledInterruptedException
- if the request is interruptedExecutionException
- if the request fails
-
getFuture
Gets aFuture
from the cache. Ifobs == null
, then theOp
associated withkey
will be executed synchronously, and asynchronously otherwise.- Parameters:
key
- theKey
for which to retrieve aFuture
obs
- theOpObserver
to notify when the value is available- Returns:
- the
Future
associated withkey
- Throws:
ExecutionException
- if the request is synchronous and fails
-
getIfDone
Gets a value from the cache, if it is already calculated.- Parameters:
key
- theKey
for which to retrieve a value- Returns:
- the value associated with
key
, ornull
-
clear
public void clear()
-