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, 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>, Francesco Nigro <fnigro@redhat.com>
-
-
Constructor Summary
Constructors Constructor Description SyncProcessingQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
notifyAndWait()
void
notifyError()
void
notifyNoWait()
T
pop()
void
pushAndWait(T element)
-
-
-
Method Detail
-
pushAndWait
public void pushAndWait(T element) throws InterruptedException
- Throws:
InterruptedException
-
pop
public T pop()
-
notifyNoWait
public void notifyNoWait()
-
notifyAndWait
public boolean notifyAndWait()
- Returns:
- {code true} if not empty or
false
if the consumer Thread is interrupted
-
notifyError
public void notifyError()
-
-