Interface WorkQueue<T>
- Type Parameters:
T- item type
- All Known Subinterfaces:
DelayingQueue<T>,RateLimitingQueue<T>
- All Known Implementing Classes:
DefaultDelayingQueue,DefaultRateLimitingQueue,DefaultWorkQueue
public interface WorkQueue<T>
The workqueue interface defines the queue behavior.
The code has been copied from the official client and modified: WorkQueue
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an item to the queue of items which need processing.voidMarks an item as completed.get()Gets an item for processing.booleanReturns whether the queue is shutdown.intlength()Returns the current queue length, for informational purposes only.voidshutdown()Initiates a shutdown of the work queue.voidstart()Starts the work queue.
-
Method Details
-
add
Adds an item to the queue of items which need processing.- Parameters:
item- item to add
-
length
int length()Returns the current queue length, for informational purposes only.- Returns:
- current queue length
-
get
Gets an item for processing. It blocks until there is an available item.- Returns:
- the item
- Throws:
InterruptedException
-
done
Marks an item as completed. Also, it will add the same item back to the queue of items which need processing if the item was marked as dirty while processing was in progress.- Parameters:
item- specific item
-
start
void start()Starts the work queue. Can be called after shutdown to enable queue usage. -
shutdown
void shutdown()Initiates a shutdown of the work queue. All added items whose processing not started will be ignored and removed from the queue. -
isShutdown
boolean isShutdown()Returns whether the queue is shutdown.- Returns:
trueif the queue is shutdown
-