T - a type of items produced by Valve APIPausable, Valve<T>, java.lang.AutoCloseable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.concurrent.BlockingQueue<T>, java.util.Queue<T>public class Tank<T> extends java.lang.Object implements Valve<T>, java.util.concurrent.BlockingQueue<T>, java.lang.AutoCloseable
Valve reactive API.| Constructor | Description |
|---|---|
Tank(int capacity) |
Creates new instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(T t) |
|
boolean |
addAll(java.util.Collection<? extends T> c) |
|
void |
clear() |
|
void |
close() |
|
boolean |
contains(java.lang.Object o) |
|
boolean |
containsAll(java.util.Collection<?> c) |
|
int |
drainTo(java.util.Collection<? super T> c) |
|
int |
drainTo(java.util.Collection<? super T> c,
int maxElements) |
|
T |
element() |
|
void |
forEach(java.util.function.Consumer<? super T> action) |
|
void |
handle(java.util.function.BiConsumer<T,Pausable> onData,
java.util.function.Consumer<java.lang.Throwable> onError,
java.lang.Runnable onComplete) |
Register data handlers (callbacks).
|
boolean |
isEmpty() |
|
java.util.Iterator<T> |
iterator() |
|
boolean |
offer(T t) |
|
boolean |
offer(T t,
long timeout,
java.util.concurrent.TimeUnit unit) |
|
void |
pause() |
Pause data chunks flow until
Pausable.resume(). |
T |
peek() |
|
T |
poll() |
|
T |
poll(long timeout,
java.util.concurrent.TimeUnit unit) |
|
void |
put(T t) |
Inserts the specified element at the tail of this queue, waiting
for space to become available if the queue is full.
|
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) |
|
void |
resume() |
Resume data chunks flow after
Pausable.pause(). |
boolean |
retainAll(java.util.Collection<?> c) |
|
int |
size() |
|
java.util.Spliterator<T> |
spliterator() |
|
T |
take() |
|
java.lang.Object[] |
toArray() |
|
<T1> T1[] |
toArray(T1[] a) |
|
void |
whenDrain(java.lang.Runnable drainHandler) |
Provided handler is called a single time when internal capacity is maximally half full and instance is not closed.
|
public Tank(int capacity)
capacity - the capacity of this queuepublic void whenDrain(java.lang.Runnable drainHandler)
drainHandler - an handler of drain eventjava.lang.NullPointerException - if drainHandler is nullpublic void pause()
PausablePausable.resume().public void resume()
PausablePausable.pause().public void handle(java.util.function.BiConsumer<T,Pausable> onData, java.util.function.Consumer<java.lang.Throwable> onError, java.lang.Runnable onComplete)
Valvepublic void close()
close in interface java.lang.AutoCloseablepublic boolean add(T t)
public boolean addAll(java.util.Collection<? extends T> c)
addAll in interface java.util.Collection<T>public boolean offer(T t)
public void put(T t) throws java.lang.InterruptedException
put in interface java.util.concurrent.BlockingQueue<T>java.lang.InterruptedExceptionjava.lang.NullPointerExceptionjava.lang.IllegalArgumentException - if Tank is closedpublic boolean offer(T t, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer in interface java.util.concurrent.BlockingQueue<T>java.lang.InterruptedExceptionpublic void clear()
clear in interface java.util.Collection<T>public T take() throws java.lang.InterruptedException
take in interface java.util.concurrent.BlockingQueue<T>java.lang.InterruptedExceptionpublic T poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll in interface java.util.concurrent.BlockingQueue<T>java.lang.InterruptedExceptionpublic boolean remove(java.lang.Object o)
public int drainTo(java.util.Collection<? super T> c)
drainTo in interface java.util.concurrent.BlockingQueue<T>public int drainTo(java.util.Collection<? super T> c, int maxElements)
drainTo in interface java.util.concurrent.BlockingQueue<T>public boolean removeIf(java.util.function.Predicate<? super T> filter)
removeIf in interface java.util.Collection<T>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<T>public int size()
size in interface java.util.Collection<T>public boolean isEmpty()
isEmpty in interface java.util.Collection<T>public int remainingCapacity()
remainingCapacity in interface java.util.concurrent.BlockingQueue<T>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<T>public boolean contains(java.lang.Object o)
public java.lang.Object[] toArray()
toArray in interface java.util.Collection<T>public <T1> T1[] toArray(T1[] a)
toArray in interface java.util.Collection<T>public java.util.Iterator<T> iterator()
public java.util.Spliterator<T> spliterator()
Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.