T
- Type of data stored in Queuepublic class Queue<T> extends java.lang.Object implements Adapter<T>
Modifier and Type | Class and Description |
---|---|
static class |
Queue.ClosedQueueException
Exception thrown if Queue closed
|
static class |
Queue.NIL |
static class |
Queue.QueueReader<T> |
static class |
Queue.QueueTimeoutException
Exception thrown if Queue polling timesout
|
Constructor and Description |
---|
Queue()
Construct a Queue backed by a LinkedBlockingQueue
|
Queue(java.util.concurrent.BlockingQueue<T> queue)
Queue accepts a BlockingQueue to make use of Blocking semantics
|
Queue(java.util.Queue<T> q,
WaitStrategy<T> consumer,
WaitStrategy<T> producer) |
Queue(QueueFactory<T> factory)
Construct an async.Queue backed by a JDK Queue from the provided QueueFactory
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T data)
Add a single data point to the queue
If the queue is a bounded queue and is full, will return false
|
void |
addContinuation(Continuation c) |
boolean |
close()
Close this Queue
Poison Pills are used to communicate closure to connected Streams
A Poison Pill is added per connected Stream to the Queue
If a BlockingQueue is backing this async.Queue it will block until
able to add to the Queue.
|
void |
closeAndClear() |
static <T> Queue<T> |
createMergeQueue() |
void |
disconnectStreams(int pillsToSend) |
boolean |
fromStream(java.util.stream.Stream<T> stream) |
T |
get() |
boolean |
isOpen() |
java.util.stream.Stream<T> |
jdkStream()
Return a standard (unextended) JDK Stream connected to this Queue
To disconnect cleanly close the queue
|
java.util.stream.Stream<T> |
jdkStream(int closeScalingFactor)
Return a standard (unextended) JDK Stream connected to this Queue
To disconnect cleanly close the queue
|
boolean |
offer(T data)
Offer a single datapoint to this Queue
If the queue is a bounded queue and is full it will block until space comes available or until
offer time out is reached (default is Integer.MAX_VALUE DAYS).
|
T |
poll(long time,
java.util.concurrent.TimeUnit unit) |
int |
size() |
ReactiveSeq<T> |
stream() |
ReactiveSeq<T> |
stream(Continueable s) |
ReactiveSeq<java.util.Collection<T>> |
streamBatch(Continueable s,
java.util.function.Function<java.util.function.BiFunction<java.lang.Long,java.util.concurrent.TimeUnit,T>,java.util.function.Supplier<java.util.Collection<T>>> batcher) |
ReactiveSeq<java.util.Collection<T>> |
streamBatchNoTimeout(Continueable s,
java.util.function.Function<java.util.function.Supplier<T>,java.util.function.Supplier<java.util.Collection<T>>> batcher) |
ReactiveSeq<java.util.concurrent.CompletableFuture<T>> |
streamCompletableFutures() |
ReactiveSeq<T> |
streamControl(Continueable s,
java.util.function.Function<java.util.function.Supplier<T>,java.util.function.Supplier<T>> batcher) |
ReactiveSeq<java.util.concurrent.CompletableFuture<T>> |
streamControlFutures(Continueable s,
java.util.function.Function<java.util.function.Supplier<T>,java.util.concurrent.CompletableFuture<T>> batcher) |
<R> R |
visit(java.util.function.Function<? super Queue<T>,? extends R> caseQueue,
java.util.function.Function<? super Topic<T>,? extends R> caseTopic)
Conditionally execute one of the supplied function depending on whether or not this Adapter is a Queue or a Topic
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
futureStream, futureStream, matches
public static final Queue.NIL NILL
public Queue()
public Queue(QueueFactory<T> factory)
factory
- QueueFactory to extract JDK Queue frompublic Queue(java.util.concurrent.BlockingQueue<T> queue)
queue
- BlockingQueue to back this Queuepublic Queue(java.util.Queue<T> q, WaitStrategy<T> consumer, WaitStrategy<T> producer)
public static <T> Queue<T> createMergeQueue()
public ReactiveSeq<T> stream()
public java.util.stream.Stream<T> jdkStream(int closeScalingFactor)
use queue.stream().parallel() to convert to a parallel Stream
closeScalingFactor
- Scaling factor for Queue closed messages to propagate to connected parallel Streamspublic java.util.stream.Stream<T> jdkStream()
use queue.stream().parallel() to convert to a parallel Stream
public ReactiveSeq<T> stream(Continueable s)
public ReactiveSeq<java.util.Collection<T>> streamBatchNoTimeout(Continueable s, java.util.function.Function<java.util.function.Supplier<T>,java.util.function.Supplier<java.util.Collection<T>>> batcher)
public ReactiveSeq<java.util.Collection<T>> streamBatch(Continueable s, java.util.function.Function<java.util.function.BiFunction<java.lang.Long,java.util.concurrent.TimeUnit,T>,java.util.function.Supplier<java.util.Collection<T>>> batcher)
public ReactiveSeq<T> streamControl(Continueable s, java.util.function.Function<java.util.function.Supplier<T>,java.util.function.Supplier<T>> batcher)
public ReactiveSeq<java.util.concurrent.CompletableFuture<T>> streamControlFutures(Continueable s, java.util.function.Function<java.util.function.Supplier<T>,java.util.concurrent.CompletableFuture<T>> batcher)
public ReactiveSeq<java.util.concurrent.CompletableFuture<T>> streamCompletableFutures()
streamCompletableFutures
in interface Adapter<T>
public boolean fromStream(java.util.stream.Stream<T> stream)
fromStream
in interface Adapter<T>
stream
- Input data from provided Streampublic T poll(long time, java.util.concurrent.TimeUnit unit) throws Queue.QueueTimeoutException
Queue.QueueTimeoutException
public T get()
public boolean add(T data)
data
- Data to addpublic boolean offer(T data)
public boolean close()
public void disconnectStreams(int pillsToSend)
pillsToSend
- Number of poison pills to send to connected Streamspublic void closeAndClear()
public int size()
public boolean isOpen()
public void addContinuation(Continuation c)
public <R> R visit(java.util.function.Function<? super Queue<T>,? extends R> caseQueue, java.util.function.Function<? super Topic<T>,? extends R> caseTopic)
Adapter