Class Cache.Work.Wait

java.lang.Object
org.apache.sis.util.collection.Cache.Work.Wait
All Implemented Interfaces:
Cache.Handler<V>
Enclosing class:
Cache.Work

final class Cache.Work.Wait extends Object implements Cache.Handler<V>
A handler implementation used when the value is in process of being computed in another thread. At the difference of the Simple handler, the computation is not yet completed, so this handler has to wait.
  • Constructor Details

    • Wait

      Wait()
  • Method Details

    • peek

      public V peek()
      Waits that the worker finish its work and returns its value.
      Specified by:
      peek in interface Cache.Handler<V>
      Returns:
      the value from the cache, or null if none.
    • putAndUnlock

      public void putAndUnlock(V result) throws IllegalStateException
      Do nothing (except checking for programming error), since we don't hold any lock.
      Implementation note: An alternative would have been to store the result in the map anyway. But doing so is unsafe because we have no lock; we have no guarantee that nothing has happened in another thread between peek and putAndUnlock.
      Specified by:
      putAndUnlock in interface Cache.Handler<V>
      Parameters:
      result - the result to store in the cache, or null for removing the entry from the cache. If an entry is removed, a new computation will be attempted the next time a handler is created for the same key.
      Throws:
      IllegalStateException - may be thrown if this method is not invoked in the pattern described in class javadoc, or if a key collision occurs.