public class WorkQueue extends Object
Constructor and Description |
---|
WorkQueue(int maxQueueSize)
Create a work queue with a maximum number of worker threads and a maximum workload queue size.
|
Modifier and Type | Method and Description |
---|---|
void |
addException(Exception exception)
Add a specific exception to the work queue.
|
List<Exception> |
getExceptions()
Return any runtime exception that occurred in the threads.
|
boolean |
isEmptyAndFinished()
Check if there is workload available, or a thread is processing workload still.
|
void |
scheduleShutdown()
Schedule shutdown for all threads after they finished their work.
|
void |
startOrWait(Runnable workLoad)
Start workload, or wait if there is too much workload in the queue.
|
void |
startOrWait(Runnable workLoad,
long timeout)
Start workload, or wait if there is too much workload in the queue.
|
boolean |
waitUntilFinished()
Wait until the work pool finished executing all work load.
|
boolean |
waitUntilFinished(long timeout)
Wait until the work pool finished executing all work load.
|
public WorkQueue(int maxQueueSize)
maxQueueSize
- Maximum work load queue size.public void scheduleShutdown()
public void startOrWait(@Nonnull Runnable workLoad, long timeout)
workLoad
- Workload to be started.timeout
- Timeout in millis. If there is no room left in the queue before this timeout expires, the
workload is discarded and not scheduled. Use 0 for wait 'forever'.public void startOrWait(@Nonnull Runnable workLoad)
workLoad
- Workload to be started.public boolean waitUntilFinished(long timeout)
timeout
- Max. wait time in msecs. Use 0 for 'forever'.public boolean waitUntilFinished()
public boolean isEmptyAndFinished()
public void addException(@Nonnull Exception exception)
exception
- Exception to be added.Copyright © 2018 TomTom International BV. All rights reserved.