Package org.jgroups.util
Class ConcurrentLinkedBlockingQueue<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.ConcurrentLinkedQueue<T>
-
- org.jgroups.util.ConcurrentLinkedBlockingQueue<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.concurrent.BlockingQueue<T>
,java.util.Queue<T>
public class ConcurrentLinkedBlockingQueue<T> extends java.util.concurrent.ConcurrentLinkedQueue<T> implements java.util.concurrent.BlockingQueue<T>
Concurrent queue which offers optional blocking on empty / full. Designed for multiple producers, but only a single consumer. Only methods required by message bundlers (offer(), poll(), drainTo(), size() etc) are implemented. Might add more implementation as needed.
See https://issues.redhat.com/browse/JGRP-2890 for details- Since:
- 5.5.0
- Author:
- Bela Ban
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
block_on_empty
protected boolean
block_on_full
protected int
capacity
protected java.util.function.IntUnaryOperator
INCR
protected java.util.concurrent.locks.Lock
lock
protected java.util.concurrent.locks.Condition
not_empty
protected java.util.concurrent.locks.Condition
not_full
protected java.util.concurrent.atomic.AtomicInteger
size
-
Constructor Summary
Constructors Constructor Description ConcurrentLinkedBlockingQueue(int capacity, boolean block_on_empty, boolean block_on_full)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T t)
boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
int
drainTo(java.util.Collection<? super T> c)
int
drainTo(java.util.Collection<? super T> c, int max)
boolean
isEmpty()
boolean
offer(T t)
boolean
offer(T t, long timeout, java.util.concurrent.TimeUnit unit)
T
poll()
T
poll(long timeout, java.util.concurrent.TimeUnit unit)
void
put(T t)
int
remainingCapacity()
T
remove()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
removeIf(java.util.function.Predicate<? super T> filter)
boolean
retainAll(java.util.Collection<?> c)
protected void
signalNotEmpty()
protected void
signalNotFull()
int
size()
T
take()
-
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
contains, forEach, iterator, peek, spliterator, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
capacity
protected final int capacity
-
size
protected final java.util.concurrent.atomic.AtomicInteger size
-
block_on_empty
protected final boolean block_on_empty
-
block_on_full
protected final boolean block_on_full
-
lock
protected final java.util.concurrent.locks.Lock lock
-
not_empty
protected final java.util.concurrent.locks.Condition not_empty
-
not_full
protected final java.util.concurrent.locks.Condition not_full
-
INCR
protected final java.util.function.IntUnaryOperator INCR
-
-
Method Detail
-
put
public void put(T t) throws java.lang.InterruptedException
- Specified by:
put
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
add
public boolean add(T t)
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
-
offer
public boolean offer(T t)
-
offer
public boolean offer(T t, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
offer
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
clear
public void clear()
-
isEmpty
public boolean isEmpty()
-
poll
public T poll()
-
poll
public T poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
poll
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
take
public T take() throws java.lang.InterruptedException
- Specified by:
take
in interfacejava.util.concurrent.BlockingQueue<T>
- Throws:
java.lang.InterruptedException
-
drainTo
public int drainTo(java.util.Collection<? super T> c)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<T>
-
drainTo
public int drainTo(java.util.Collection<? super T> c, int max)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<T>
-
remove
public T remove()
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
removeIf
public boolean removeIf(java.util.function.Predicate<? super T> filter)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
size
public int size()
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interfacejava.util.concurrent.BlockingQueue<T>
-
signalNotEmpty
protected void signalNotEmpty()
-
signalNotFull
protected void signalNotFull()
-
-