|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.gui.jmapviewer.JobDispatcher
public class JobDispatcher
A generic class that processes a list of Runnable
one-by-one using
one or more JobDispatcher.JobThread
-instances. The number of instances varies between
1 and WORKER_THREAD_MAX_COUNT
(default: 8). If an instance is idle
more than WORKER_THREAD_TIMEOUT
seconds (default: 30), the instance
ends itself.
Nested Class Summary | |
---|---|
class |
JobDispatcher.JobThread
|
Field Summary | |
---|---|
private static JobDispatcher |
instance
|
protected java.util.concurrent.BlockingDeque<TileJob> |
jobQueue
|
protected boolean |
modeLIFO
Type of queue, FIFO if false , LIFO if true |
static int |
WORKER_THREAD_MAX_COUNT
|
static int |
WORKER_THREAD_TIMEOUT
Specifies the time span in seconds that a worker thread waits for new jobs to perform. |
protected int |
workerThreadCount
Total number of worker threads currently idle or active |
protected int |
workerThreadId
Just an id for identifying an worker thread instance |
protected int |
workerThreadIdleCount
Number of worker threads currently idle |
Constructor Summary | |
---|---|
private |
JobDispatcher()
|
Method Summary | |
---|---|
void |
addJob(TileJob job)
Adds a job to the queue. |
protected JobDispatcher.JobThread |
addWorkerThread()
|
void |
cancelOutstandingJobs()
Removes all jobs from the queue that are currently not being processed. |
static JobDispatcher |
getInstance()
|
void |
setLIFO(boolean lifo)
Function to set the LIFO/FIFO mode for tile loading job. |
static void |
setMaxWorkers(int workers)
Function to set the maximum number of workers for tile loading. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final JobDispatcher instance
protected java.util.concurrent.BlockingDeque<TileJob> jobQueue
public static int WORKER_THREAD_MAX_COUNT
public static int WORKER_THREAD_TIMEOUT
protected boolean modeLIFO
false
, LIFO if true
protected int workerThreadCount
protected int workerThreadIdleCount
protected int workerThreadId
Constructor Detail |
---|
private JobDispatcher()
Method Detail |
---|
public static JobDispatcher getInstance()
JobDispatcher
public void cancelOutstandingJobs()
public static void setMaxWorkers(int workers)
public void setLIFO(boolean lifo)
lifo
- true
for LIFO mode, false
for FIFO modepublic void addJob(TileJob job)
null
tile
prevents skipping).
job
- the the job to be addedprotected JobDispatcher.JobThread addWorkerThread()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |