Package net.toddm.comm
Class CachedResponseFuture
- java.lang.Object
-
- java.util.concurrent.FutureTask<Response>
-
- net.toddm.comm.CachedResponseFuture
-
- All Implemented Interfaces:
Runnable,Future<Response>,RunnableFuture<Response>
public class CachedResponseFuture extends FutureTask<Response>
This is a simple no-opFutureTaskimplementation that simply wraps and returns a cachedResponse. We provide this wrapping so that no special case code is ever required. Client code can still be written to, for example, block on future get() wait handles. In this case of cached results this will simply return the cached result immediately.- Author:
- Todd S. Murchison
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCachedResponseFuture(Response cachedResponse)Constructors aFutureTaskinstance that always immediately returns the given Response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Responseget()Immediately returns the cachedResponse.Responseget(long timeout, TimeUnit unit)Immediately returns the cachedResponse.booleanisCancelled()Always returns FALSE.booleanisDone()Always returns TRUE.voidrun()Does nothing.-
Methods inherited from class java.util.concurrent.FutureTask
cancel, done, runAndReset, set, setException, toString
-
-
-
-
Constructor Detail
-
CachedResponseFuture
protected CachedResponseFuture(Response cachedResponse)
Constructors aFutureTaskinstance that always immediately returns the given Response.
-
-
Method Detail
-
isCancelled
public boolean isCancelled()
Always returns FALSE.- Specified by:
isCancelledin interfaceFuture<Response>- Overrides:
isCancelledin classFutureTask<Response>
-
isDone
public boolean isDone()
Always returns TRUE.
-
run
public void run()
Does nothing.- Specified by:
runin interfaceRunnable- Specified by:
runin interfaceRunnableFuture<Response>- Overrides:
runin classFutureTask<Response>
-
-