Essentially, it uses BatchWorker as Callable/Future with a collection argument.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ThreadedWorkQueue.BatchWorker<WW>
Callback class, think of it as a Runnable with an argument that is
a |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final ThreadedWorkQueue. | |
| private final AtomicInteger | |
| private volatile boolean | |
| private static final int | |
| private final AtomicInteger | |
| private final AtomicInteger | |
| private final LinkedBlockingQueue | |
| private final ExecutorService |
| Access | Constructor and Description |
|---|---|
| public | ThreadedWorkQueue(ThreadedWorkQueue.
Thread safe dispatcher to use to dispatch work dispatcher,Number of parallel threads used process work from this queue numberOfThreads, ThreadFactory ThreadFactory used to create the threadsmaximum backlog of work items that can be queued before items get dropped maximumQueueSize, int number of items, at a maximum, to send to a dispatcher at a time. batchSize)Create a work queue where work is dispatched through the given dispatcher, which the specified number of threads. |
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public int | |
| public ThreadedWorkQueue. | |
| public int | |
| public int | |
| public int | |
| public boolean | |
| public void | |
| private void | |
| public void |
| batchSize | back to summary |
|---|---|
| private final int batchSize | |
| dispatcher | back to summary |
|---|---|
| private final ThreadedWorkQueue. | |
| droppedCounter | back to summary |
|---|---|
| private final AtomicInteger droppedCounter | |
| isAlive | back to summary |
|---|---|
| private volatile boolean isAlive | |
| MINUTES_OF_THE_IDLE_LIFE | back to summary |
|---|---|
| private static final int MINUTES_OF_THE_IDLE_LIFE | |
| offerCounter | back to summary |
|---|---|
| private final AtomicInteger offerCounter | |
| processedCounter | back to summary |
|---|---|
| private final AtomicInteger processedCounter | |
| queue | back to summary |
|---|---|
| private final LinkedBlockingQueue<W> queue | |
| threadPool | back to summary |
|---|---|
| private final ExecutorService threadPool | |
| ThreadedWorkQueue | back to summary |
|---|---|
| public ThreadedWorkQueue(ThreadedWorkQueue. Create a work queue where work is dispatched through the given dispatcher, which the specified number of threads.
| |
| getBacklogCount | back to summary |
|---|---|
| public long getBacklogCount() Get the current backlog count. An approximation, by necessity.
| |
| getBatchSize | back to summary |
|---|---|
| public int getBatchSize() Get the batch size
| |
| getDispatcher | back to summary |
|---|---|
| public ThreadedWorkQueue. get the dispatcher being used for this queue.
| |
| getDroppedCount | back to summary |
|---|---|
| public int getDroppedCount() Gets dropped counter.
| |
| getOfferedCount | back to summary |
|---|---|
| public int getOfferedCount() Gets offer counter. Cumulative tripped
| |
| getProcessedCount | back to summary |
|---|---|
| public int getProcessedCount() Gets processed count.
| |
| isAlive | back to summary |
|---|---|
| public boolean isAlive() Is this work queue still accepting work.
| |
| offer | back to summary |
|---|---|
| public void offer(W workUnit) Offer a work unit to queue. Might push prior work units off of the work queue, dropped forever. | |
| pullFromQueueAndDispatch | back to summary |
|---|---|
| private void pullFromQueueAndDispatch() throws InterruptedException Actually do the work. | |
| shutdown | back to summary |
|---|---|
| public void shutdown() Shutdown this queue. Propagates an interrupt to currently executing | |
Collection.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| process | back to summary |
|---|---|
| public void process(Collection<? extends WW> collection) Process a batch of work. | |