public Stream<T> jdkStream(final Continueable s){ this.sub = s; listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return closingStream(this::get, s); } @Override
@Override public ReactiveSeq<T> stream(final Continueable s) { this.sub = s; listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(this::get, s)); }
/** * @return Sequential Infinite (until Queue is closed) Stream of data from * this Queue * */ @Override public ReactiveSeq<T> stream() { listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(this::get, new AlwaysContinue())); } /**
/** * Return a standard (unextended) JDK Stream connected to this Queue * To disconnect cleanly close the queue * * <pre> * {@code * use queue.stream().parallel() to convert to a parallel Stream * } * </pre> * * @param closeScalingFactor Scaling factor for Queue closed messages to propagate to connected parallel Streams. * Scaling Factor may need to be high to reach all connect parallel threads. * * @return Java 8 Stream connnected to this Queue */ public Stream<T> jdkStream(int closeScalingFactor){ int cores = Runtime.getRuntime().availableProcessors(); String par = System.getProperty("java.util.concurrent.ForkJoinPool.common.parallelism"); int connected = par !=null ? Integer.valueOf(par) : cores; int update = 0; do{ update = listeningStreams.get()+ connected*closeScalingFactor; }while(!listeningStreams.compareAndSet(listeningStreams.get(), update)); return closingStream(this::get, new AlwaysContinue()); }
public ReactiveSeq<T> streamControl(final Continueable s, final Function<Supplier<T>, Supplier<T>> batcher) { listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(batcher.apply(() -> ensureOpen(this.timeout, this.timeUnit)), s)); }
public Stream<T> jdkStream(final Continueable s){ this.sub = s; listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return closingStream(this::get, s); } @Override
@Override public ReactiveSeq<T> stream(final Continueable s) { this.sub = s; listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(this::get, s)); }
public ReactiveSeq<T> streamControl(final Continueable s, final Function<Supplier<T>, Supplier<T>> batcher) { listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(batcher.apply(() -> ensureOpen(this.timeout, this.timeUnit)), s)); }
/** * @return Sequential Infinite (until Queue is closed) Stream of data from * this Queue * */ @Override public ReactiveSeq<T> stream() { listeningStreams.incrementAndGet(); //assumes all Streams that ever connected, remain connected return ReactiveSeq.fromStream(closingStream(this::get, new AlwaysContinue())); } /**
/** * Return a standard (unextended) JDK Stream connected to this Queue * To disconnect cleanly close the queue * * <pre> * {@code * use queue.stream().parallel() to convert to a parallel Stream * } * </pre> * * @param closeScalingFactor Scaling factor for Queue closed messages to propagate to connected parallel Streams. * Scaling Factor may need to be high to reach all connect parallel threads. * * @return Java 8 Stream connnected to this Queue */ public Stream<T> jdkStream(int closeScalingFactor){ int cores = Runtime.getRuntime().availableProcessors(); String par = System.getProperty("java.util.concurrent.ForkJoinPool.common.parallelism"); int connected = par !=null ? Integer.valueOf(par) : cores; int update = 0; do{ update = listeningStreams.get()+ connected*closeScalingFactor; }while(!listeningStreams.compareAndSet(listeningStreams.get(), update)); return closingStream(this::get, new AlwaysContinue()); }