Package org.jgroups.util
Class ProcessingQueue<T>
- java.lang.Object
-
- org.jgroups.util.ProcessingQueue<T>
-
public class ProcessingQueue<T> extends java.lang.Object
A queue with many producers and consumers. However, only one consumer gets to remove and process elements at any given time. This is done through the use of locks.- Since:
- 3.5
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ProcessingQueue.Handler<T>
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.locks.ReentrantLock
consumer_lock
protected int
count
protected ProcessingQueue.Handler<T>
handler
protected java.util.concurrent.locks.ReentrantLock
producer_lock
protected java.util.Queue<T>
queue
-
Constructor Summary
Constructors Constructor Description ProcessingQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T element)
java.util.Queue<T>
getQueue()
protected void
process()
boolean
retainAll(java.util.Collection<T> elements)
ProcessingQueue<T>
setHandler(ProcessingQueue.Handler<T> handler)
int
size()
java.lang.String
toString()
-
-
-
Field Detail
-
queue
protected final java.util.Queue<T> queue
-
producer_lock
protected final java.util.concurrent.locks.ReentrantLock producer_lock
-
consumer_lock
protected final java.util.concurrent.locks.ReentrantLock consumer_lock
-
count
protected int count
-
handler
protected ProcessingQueue.Handler<T> handler
-
-
Method Detail
-
getQueue
public java.util.Queue<T> getQueue()
-
size
public int size()
-
setHandler
public ProcessingQueue<T> setHandler(ProcessingQueue.Handler<T> handler)
-
add
public void add(T element)
-
retainAll
public boolean retainAll(java.util.Collection<T> elements)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
process
protected void process()
-
-