/** * Construct a Topic using the Queue provided * @param q Queue to back this Topic with */ public Topic(final Queue<T> q) { factory = QueueFactories.unboundedQueue(); distributor.addQueue(q); } public Topic(final Queue<T> q,QueueFactory<T> factory) {
/** * Construct a new Topic */ public Topic() { final Queue<T> q = new Queue<T>(); factory = QueueFactories.unboundedQueue(); distributor.addQueue(q); }
@Test public void adapter(){ Adapter<Integer> adapter = QueueFactories.<Integer>unboundedQueue() .build(); String result = Eithers.adapter(adapter) .fold(queue->"we have a queue", topic->"we have a topic"); assertThat(result,equalTo("we have a queue")); }
/** * Construct a Topic using the Queue provided * @param q Queue to back this Topic with */ public Topic(final Queue<T> q) { factory = QueueFactories.unboundedQueue(); distributor.addQueue(q); } public Topic(final Queue<T> q,QueueFactory<T> factory) {
public SimpleReactStreamImpl(final SimpleReact simpleReact, final Stream<CompletableFuture<U>> stream) { this.simpleReact = simpleReact; final Stream s = stream; this.errorHandler = Optional.empty(); this.lastActive = new EagerStreamWrapper( s, this.errorHandler); this.queueFactory = QueueFactories.unboundedQueue(); this.subscription = new AlwaysContinue(); }
/** * Construct a new Topic */ public Topic() { final Queue<T> q = new Queue<T>(); factory = QueueFactories.unboundedQueue(); distributor.addQueue(q); }
this.withQueueFactory(QueueFactories.unboundedQueue()) .toQueue(q -> q.withTimeout(100) .withTimeUnit(TimeUnit.MICROSECONDS)),
/** * @return a Stream that batches all completed elements from this stream since last read recover into a collection */ default FutureStream<Collection<U>> chunkSinceLastRead() { final Queue queue = this.withQueueFactory(QueueFactories.unboundedQueue()) .toQueue(); final Queue.QueueReader reader = new Queue.QueueReader( queue, null); class Chunker implements Iterator<Collection<U>> { @Override public boolean hasNext() { return reader.isOpen(); } @Override public Collection<U> next() { return reader.drainToOrBlock(); } } final Chunker chunker = new Chunker(); final Function<Supplier<U>, Supplier<Collection<U>>> fn = s -> { return () -> { try { return chunker.next(); } catch (final ClosedQueueException e) { throw new ClosedQueueException(); } }; }; return fromStream(queue.streamBatchNoTimeout(getSubscription(), fn)); }