Package org.apache.sis.util.collection
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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionpeek()
Waits that the worker finish its work and returns its value.void
putAndUnlock
(V result) Do nothing (except checking for programming error), since we don't hold any lock.
-
Constructor Details
-
Wait
Wait()
-
-
Method Details
-
peek
Waits that the worker finish its work and returns its value.- Specified by:
peek
in interfaceCache.Handler<V>
- Returns:
- the value from the cache, or
null
if none.
-
putAndUnlock
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 betweenpeek
andputAndUnlock
.- Specified by:
putAndUnlock
in interfaceCache.Handler<V>
- Parameters:
result
- the result to store in the cache, ornull
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.
-