Class DefaultWorkQueue<T>
java.lang.Object
io.micronaut.kubernetes.client.openapi.operator.workqueue.DefaultWorkQueue<T>
- Type Parameters:
T
- item type
- All Implemented Interfaces:
WorkQueue<T>
- Direct Known Subclasses:
DefaultDelayingQueue
The default
WorkQueue
implementation that uses a doubly-linked list to store work items.
This class ensures the added work items are not in dirty set nor in currently processing set before
adding them to the list.
The code has been copied from the official client and modified: DefaultWorkQueue
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an item to the queue of items which need processing.void
Marks an item as completed.get()
Gets an item for processing.boolean
Returns whether the queue is shutdown.int
length()
Returns the current queue length, for informational purposes only.void
shutdown()
Initiates a shutdown of the work queue.void
start()
Starts the work queue.
-
Constructor Details
-
DefaultWorkQueue
public DefaultWorkQueue()
-
-
Method Details
-
add
Description copied from interface:WorkQueue
Adds an item to the queue of items which need processing. -
length
public int length()Description copied from interface:WorkQueue
Returns the current queue length, for informational purposes only. -
get
Description copied from interface:WorkQueue
Gets an item for processing. It blocks until there is an available item.- Specified by:
get
in interfaceWorkQueue<T>
- Returns:
- the item
- Throws:
InterruptedException
-
done
Description copied from interface:WorkQueue
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. -
start
public void start()Description copied from interface:WorkQueue
Starts the work queue. Can be called after shutdown to enable queue usage. -
shutdown
public void shutdown()Description copied from interface:WorkQueue
Initiates a shutdown of the work queue. All added items whose processing not started will be ignored and removed from the queue. -
isShutdown
public boolean isShutdown()Description copied from interface:WorkQueue
Returns whether the queue is shutdown.- Specified by:
isShutdown
in interfaceWorkQueue<T>
- Returns:
true
if the queue is shutdown
-