public class CacheDispatcher
extends java.lang.Thread
ResponseDelivery
. Cache misses and responses that require
refresh are enqueued on the specified network queue for processing
by a NetworkDispatcher
.Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG |
private Cache |
mCache
The cache to read from.
|
private java.util.concurrent.BlockingQueue<Request<?>> |
mCacheQueue
The queue of requests coming in for triage.
|
private ResponseDelivery |
mDelivery
For posting responses.
|
private java.util.concurrent.BlockingQueue<Request<?>> |
mNetworkQueue
The queue of requests going out to the network.
|
private boolean |
mQuit
Used for telling us to die.
|
Constructor and Description |
---|
CacheDispatcher(java.util.concurrent.BlockingQueue<Request<?>> cacheQueue,
java.util.concurrent.BlockingQueue<Request<?>> networkQueue,
Cache cache,
ResponseDelivery delivery)
Creates a new cache triage dispatcher thread.
|
Modifier and Type | Method and Description |
---|---|
void |
quit()
Forces this dispatcher to quit immediately.
|
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private static final boolean DEBUG
private final java.util.concurrent.BlockingQueue<Request<?>> mCacheQueue
private final java.util.concurrent.BlockingQueue<Request<?>> mNetworkQueue
private final Cache mCache
private final ResponseDelivery mDelivery
private volatile boolean mQuit
public CacheDispatcher(java.util.concurrent.BlockingQueue<Request<?>> cacheQueue, java.util.concurrent.BlockingQueue<Request<?>> networkQueue, Cache cache, ResponseDelivery delivery)
Thread.start()
in order to begin processing.cacheQueue
- Queue of incoming requests for triagenetworkQueue
- Queue to post requests that require network tocache
- Cache interface to use for resolutiondelivery
- Delivery interface to use for posting responses