Package VASSAL.tools.opcache
Class AbstractOpImpl<V>
java.lang.Object
VASSAL.tools.opcache.AbstractOpImpl<V>
- All Implemented Interfaces:
Op<V>
- Direct Known Subclasses:
AbstractOpImpl
An abstract representation of an operation.
AbstractOpImpl
is the base class for all such operations. The results of all operations
are memoized (using a memory-sensitive cache), so retrieving results is
both fast and memory-efficient.
Warning: For efficiency reasons, the methods get() and
get(OpObserver) do not return defensively, nor do the
Futures returned by getFuture(OpObserver). That is, the
object returned is possibly the one retained internally by the
AbstractOpImpl. Therefore, objects obtained from an
AbstractOpImpl must not be altered, as this might
interfere with caching. If an object obtained this way needs to be
modified, copy the object first and alter the copy.
- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
cache
The cache which contains calculated results.
-
-
Constructor Details
-
AbstractOpImpl
- Parameters:
cache- the cache for storing our result
-
-
Method Details
-
getSources
Returns a list ofOps on which thisOpdepends.- Specified by:
getSourcesin interfaceOp<V>- Returns:
- the
Ops on which thisOpdepends
-
eval
Runs theOp. This method should be called only by the caching framework. -
get
-
get
public V get(OpObserver<V> obs) throws CancellationException, InterruptedException, ExecutionException- Throws:
CancellationException- if the operation was cancelledInterruptedException- if the operation was interruptedExecutionException- if the operation failed
-
getFuture
- Throws:
CancellationException- if the operation was cancelledInterruptedException- if the operation was interruptedExecutionException- if the operation failed
-
newKey
Returns the current cache key for thisOp. -
update
public void update()Invalidates the current cache key for thisOp.
-