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 java.lang.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 - marcelv3612@gmail.com
-
-
Constructor Summary
Constructors Constructor Description Memoizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vcompute(ComputableTask<A,V> c, A taskArg)Waits if necessary for the computation to complete, and then retrieves its result.voidforget(ComputableTask<A,V> task, A key)Forgets result of the specified task.voidforgetAll()Forgets all cached results.
-
-
-
Method Detail
-
compute
public V compute(ComputableTask<A,V> c, A taskArg) throws java.lang.InterruptedException
Description copied from interface:LowLevelProcessorWaits if necessary for the computation to complete, and then retrieves its result.- Specified by:
computein interfaceLowLevelProcessor<A,V>taskArg- argument for computation- Throws:
java.lang.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.
-
-