Class Memoizer<A,V>
- java.lang.Object
-
- org.eclipse.persistence.internal.cache.Memoizer<A,V>
-
- All Implemented Interfaces:
LowLevelProcessor<A,V>
public class Memoizer<A,V> extends Object implements LowLevelProcessor<A,V>
Memoizer for computing resource expensive tasks asynchronously & concurrently. Inspired by D. Lea. JCiP, 2nd edition. Addison-Wesley, 2006. pp.109- Since:
- 2.6
- Author:
- Marcel Valovy - [email protected]
-
-
Constructor Summary
Constructors Constructor Description Memoizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
compute(ComputableTask<A,V> c, A taskArg)
Waits if necessary for the computation to complete, and then retrieves its result.void
forget(ComputableTask<A,V> task, A key)
Forgets result of the specified task.void
forgetAll()
Forgets all cached results.
-
-
-
Method Detail
-
compute
public V compute(ComputableTask<A,V> c, A taskArg) throws InterruptedException
Description copied from interface:LowLevelProcessor
Waits if necessary for the computation to complete, and then retrieves its result.- Specified by:
compute
in interfaceLowLevelProcessor<A,V>
taskArg
- argument for computation- Throws:
InterruptedException
- if the current thread was interrupted while waiting
-
forget
public void forget(ComputableTask<A,V> task, A key)
Forgets result of the specified task. This allows to manually control size of internal cache.- Parameters:
task
- computable task, forming part of result keykey
- argument of computation
-
forgetAll
public void forgetAll()
Forgets all cached results.
-
-