Class GAsyncWorkQueue<T>
java.lang.Object
com.glitchybyte.glib.concurrent.workqueue.GAsyncWorkQueue<T>
- Type Parameters:
T- Type of work item.
A queue of work with the following characteristics:
- Able to queue work items from multiple threads with minimal lock contention.
- Work is serviced separately from the queue, allowing work to be performed without blocking the queue.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
GAsyncWorkQueue
public GAsyncWorkQueue()Creates an asynchronous work queue.
-
-
Method Details
-
addWork
Adds a work item to the queue.- Parameters:
item- Work item.
-
awaitWork
Awaits for work to be queued.awaitWorkanddoWorkmust be called on the same thread.- Throws:
InterruptedException- If the thread is interrupted while awaiting.
-
doWork
Performs work on every item queued.awaitWorkanddoWorkmust be called on the same thread.- Parameters:
itemConsumer- Consumer that performs work on items.
-