Package org.infinispan.persistence.sifs
Class SyncProcessingQueue<T>
- java.lang.Object
-
- org.infinispan.persistence.sifs.SyncProcessingQueue<T>
-
public class SyncProcessingQueue<T> extends Object
Multiple producer-single consumer queue. The producers are expected to call pushAndWait(), the consumer should call pop() in a loop and if a null is returned (meaning that the queue is either empty or the limit of elements processed in a loop has been reached, to call notifyAndWait(). Example: while (running) { T element = queue.pop(); if (element != null) { process(element); } else { flush(); queue.notifyAndWait(); } } // terminate producers and process the rest of the queue queue.notifyNoWait();- Author:
- Radim Vansa <rvansa@redhat.com>
-
-
Constructor Summary
Constructors Constructor Description SyncProcessingQueue()
SyncProcessingQueue(int maxPoppedInRow)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
notifyAndWait()
void
notifyError()
void
notifyNoWait()
T
pop()
long
push(T element)
void
pushAndWait(T element)
protected void
waitFor(long myIndex)
-
-
-
Method Detail
-
pushAndWait
public void pushAndWait(T element) throws InterruptedException
- Throws:
InterruptedException
-
push
public long push(T element)
-
waitFor
protected void waitFor(long myIndex) throws InterruptedException
- Throws:
InterruptedException
-
pop
public T pop()
-
notifyAndWait
public void notifyAndWait()
-
notifyNoWait
public void notifyNoWait()
-
notifyError
public void notifyError()
-
-