Class OpCache

java.lang.Object
VASSAL.tools.opcache.OpCache

public class OpCache extends Object
A memory-sensitive cache for Ops and their results.
Since:
3.1.0
Author:
Joel Uckelman
  • Field Details

  • Constructor Details

    • OpCache

      public OpCache()
  • Method Details

    • get

      public <V> V get(OpCache.Key<V> key)
      Gets a value from the cache.
      Parameters:
      key - the Key for which to retrieve a value
      Returns:
      the value associated with key
    • get

      Gets a value from the cache, possibly asynchronously.
      Parameters:
      key - the Key for which to retrieve a value
      obs - the OpObserver to notify when the value is available
      Returns:
      the value associated with key
      Throws:
      CancellationException - if the request is cancelled
      InterruptedException - if the request is interrupted
      ExecutionException - if the request fails
    • getFuture

      public <V> Future<V> getFuture(OpCache.Key<V> key, OpObserver<V> obs) throws ExecutionException
      Gets a Future from the cache. If obs == null, then the Op associated with key will be executed synchronously, and asynchronously otherwise.
      Parameters:
      key - the Key for which to retrieve a Future
      obs - the OpObserver to notify when the value is available
      Returns:
      the Future associated with key
      Throws:
      ExecutionException - if the request is synchronous and fails
    • getIfDone

      public <V> V getIfDone(OpCache.Key<V> key)
      Gets a value from the cache, if it is already calculated.
      Parameters:
      key - the Key for which to retrieve a value
      Returns:
      the value associated with key, or null
    • clear

      public void clear()