public class DefaultWorkQueue<T> extends Object implements WorkQueue<T>
WorkQueue implementation that uses a doubly-linked list to store work items.
This class ensures the added work items are, not in dirty set or currently processing set, before
append them to the list.
Usage example, based on a typical producer-consumer scenario.
| Constructor and Description |
|---|
DefaultWorkQueue() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(T item)
add marks item as needing processing.
|
void |
done(T item)
Done marks item as done processing, and if it has been marked as dirty again,
|
T |
get()
Get blocks until it can return an item to be processed.
|
boolean |
isShuttingDown()
returns whether the queue shutdown.
|
int |
length()
length returns the current queue length, for informational purposes only.
|
void |
shutDown()
ShutDown will cause q to ignore all new items added to it.
|
public void add(T item)
WorkQueuepublic int length()
WorkQueuepublic T get() throws InterruptedException
WorkQueueget in interface WorkQueue<T>InterruptedExceptionpublic void done(T item)
WorkQueuepublic void shutDown()
WorkQueuepublic boolean isShuttingDown()
WorkQueueisShuttingDown in interface WorkQueue<T>true if theCopyright © 2023. All rights reserved.