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)
WorkQueue
public int length()
WorkQueue
public T get() throws InterruptedException
WorkQueue
get
in interface WorkQueue<T>
InterruptedException
public void done(T item)
WorkQueue
public void shutDown()
WorkQueue
public boolean isShuttingDown()
WorkQueue
isShuttingDown
in interface WorkQueue<T>
true
if theCopyright © 2021. All rights reserved.