public class JobDispatcher
extends java.lang.Object
Runnable
one-by-one using
one or more Thread
-instances. The number of instances varies between
1 and workerThreadMaxCount
(default: 8). If an instance is idle
more than workerThreadTimeout
seconds (default: 30), the instance
ends itself.Modifier and Type | Class and Description |
---|---|
class |
JobDispatcher.JobThread |
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.BlockingDeque<TileJob> |
jobQueue |
protected boolean |
modeLIFO
Type of queue, FIFO if
false , LIFO if true |
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
|
protected static int |
workerThreadMaxCount |
protected static int |
workerThreadTimeout
Specifies the time span in seconds that a worker thread waits for new
jobs to perform.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected java.util.concurrent.BlockingDeque<TileJob> jobQueue
protected static int workerThreadMaxCount
protected static int workerThreadTimeout
protected boolean modeLIFO
false
, LIFO if true
protected int workerThreadCount
protected int workerThreadIdleCount
protected int workerThreadId
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()