Tabnine Logo
Queue.stream
Code IndexAdd Tabnine to your IDE (free)

How to use
stream
method
in
com.oath.cyclops.async.adapters.Queue

Best Java code snippets using com.oath.cyclops.async.adapters.Queue.stream (Showing top 20 results out of 315)

origin: aol/cyclops

@Override
public ReactiveSeq<T> stream(final Continueable s) {
  return connect(q -> q.stream(s));
}
origin: aol/cyclops

/**
 * @return Infinite (until Queue is closed) Stream of CompletableFutures
 *         that can be used as input into a SimpleReact concurrent dataflow
 *
 *         This Stream itself is Sequential, SimpleReact will applyHKT
 *         concurrency / parralellism via the constituent CompletableFutures
 *
 */
@Override
public ReactiveSeq<CompletableFuture<T>> streamCompletableFutures() {
  return stream().map(CompletableFuture::completedFuture);
}
origin: aol/cyclops

/**
 * Generating a stream will register the Stream as a reactiveSubscriber to this topic.
 * It will be provided with an internal Queue as a mailbox. @see Topic.disconnect to disconnect from the topic
 * @return Stream of data
 */
@Override
public ReactiveSeq<T> stream() {
  return connect(q -> q.stream());
}
origin: aol/cyclops

private Stream<T> genJdkStream() {
  final Continueable subscription = new com.oath.cyclops.react.async.subscription.Subscription();
  return queue.stream(subscription);
}
origin: aol/cyclops

@Override
public Stream<T> unwrapStream() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
                    .build();
    AtomicBoolean wip = new AtomicBoolean(false);
    Continuation cont = new Continuation(() -> {
      if (wip.compareAndSet(false, true)) {
        this.source.subscribeAll(queue::offer, i -> {
          queue.close();
        }, () -> queue.close());
      }
      return Continuation.empty();
    });
    queue.addContinuation(cont);
    return queue.stream();
  }
  return StreamSupport.stream(new OperatorToIterable<>(source, this.defaultErrorHandler, async == BACKPRESSURE).spliterator(), false);
}
origin: aol/cyclops

@Override
public Iterator<T> iterator() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
        .build();
    AtomicBoolean wip = new AtomicBoolean(false);
    Subscription[] sub = {null};
    Continuation cont = new Continuation(() -> {
      if (wip.compareAndSet(false, true)) {
        this.source.subscribeAll(queue::offer,
            i -> queue.close(),
            () -> queue.close());
      }
      return Continuation.empty();
    });
    queue.addContinuation(cont);
    return queue.stream().iterator();
  }
  return new OperatorToIterable<>(source, this.defaultErrorHandler, async == BACKPRESSURE).iterator();
}
origin: aol/cyclops

@Test
public void publishTest() {
  for (int k = 0; k < ITERATIONS; k++) {
    Queue<Integer> queue = QueueFactories.<Integer>boundedNonBlockingQueue(10)
        .build();
    Thread t = new Thread(() -> {
      try {
        System.out.println("Sleeping!");
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      System.out.println("Waking!");
      System.out.println("Closing! " + queue.size());
      queue.close();
    });
    t.start();
    of(1, 2, 3).peek(i -> System.out.println("publishing " + i))
        .publishTo(queue)
        .forEach(System.out::println);
    assertThat(queue.stream().collect(Collectors.toList()), equalTo(Arrays.asList(1, 2, 3)));
    t = null;
    System.gc();
  }
}
origin: aol/cyclops

return queue.stream();
origin: aol/cyclops

return queue.stream();
origin: aol/cyclops

@Test
public void queueTest(){
  com.oath.cyclops.async.adapters.Queue<Integer> q = new Queue<>();
  q.add(1);
  q.add(2);
  q.add(3);
  q.stream().limit(3).forEach(System.out::println);
  q.add(4);
  q.add(5);
  q.stream().limit(2).forEach(System.out::println);
}
@Test
origin: com.oath.cyclops/cyclops

/**
 * @return Infinite (until Queue is closed) Stream of CompletableFutures
 *         that can be used as input into a SimpleReact concurrent dataflow
 *
 *         This Stream itself is Sequential, SimpleReact will applyHKT
 *         concurrency / parralellism via the constituent CompletableFutures
 *
 */
@Override
public ReactiveSeq<CompletableFuture<T>> streamCompletableFutures() {
  return stream().map(CompletableFuture::completedFuture);
}
origin: com.oath.cyclops/cyclops

/**
 * Generating a stream will register the Stream as a reactiveSubscriber to this topic.
 * It will be provided with an internal Queue as a mailbox. @see Topic.disconnect to disconnect from the topic
 * @return Stream of data
 */
@Override
public ReactiveSeq<T> stream() {
  return connect(q -> q.stream());
}
origin: com.oath.cyclops/cyclops

@Override
public ReactiveSeq<T> stream(final Continueable s) {
  return connect(q -> q.stream(s));
}
origin: com.oath.cyclops/cyclops

private Stream<T> genJdkStream() {
  final Continueable subscription = new com.oath.cyclops.react.async.subscription.Subscription();
  return queue.stream(subscription);
}
origin: com.oath.cyclops/cyclops-futurestream

private Stream<T> genJdkStream() {
  final Continueable subscription = new com.oath.cyclops.react.async.subscription.Subscription();
  return queue.stream(subscription);
}
origin: com.oath.cyclops/cyclops-futurestream

/**
 * Wrap a Stream into a SimpleReactStream.
 */
static <T> SimpleReactStream<T> simpleReactStream(Stream<T> stream) {
  if (stream instanceof FutureStream)
    stream = ((FutureStream) stream).toQueue()
                      .stream(((FutureStream) stream).getSubscription());
  final SimpleReact sr = new SimpleReact(
                      ThreadPools.getCurrentThreadExecutor(),
                      false);
  return new SimpleReactStreamImpl<T>(
                    sr, stream.map(CompletableFuture::completedFuture));
}
origin: com.oath.cyclops/cyclops-futurestream

private FutureStream<T> genStream() {
  final Continueable subscription = new com.oath.cyclops.react.async.subscription.Subscription();
  return new LazyReact().of()
      .withSubscription(subscription)
      .fromStream(queue.stream(subscription));
}
origin: com.oath.cyclops/cyclops-futurestream

default Iterator<U> iterator() {
  final Queue<U> q = toQueue();
  if (getSubscription().closed())
    return new CloseableIterator<>(
                    Arrays.<U> asList()
                       .iterator(),
                    getSubscription(), null);
  return new CloseableIterator<>(
                  q.stream(getSubscription())
                  .iterator(),
                  getSubscription(), q);
}
origin: com.oath.cyclops/cyclops-futurestream

@Override
default FutureStream<U> limit(final long maxSize) {
  final Continueable sub = this.getSubscription();
  sub.registerLimit(maxSize);
  return fromStream(ReactiveSeq.oneShotStream(toQueue().stream(sub))
                 .limit(maxSize));
}
origin: com.oath.cyclops/cyclops-futurestream

@Override
default FutureStream<U> skip(final long n) {
  final Continueable sub = this.getSubscription();
  sub.registerSkip(n);
  return fromStream(ReactiveSeq.oneShotStream(toQueue().stream(sub))
                 .skip(n));
}
com.oath.cyclops.async.adaptersQueuestream

Popular methods of Queue

  • close
    Close this Queue Poison Pills are used to communicate closure to connected Streams A Poison Pill is
  • <init>
  • offer
    Offer a single datapoint to this Queue If the queue is a bounded queue and is full it will block unt
  • jdkStream
  • closeAndClear
  • add
    Add a single data point to the queue If the queue is a bounded queue and is full, will return false
  • size
  • addContinuation
  • get
  • streamCompletableFutures
  • withTimeout
  • checkTime
  • withTimeout,
  • checkTime,
  • closingStream,
  • closingStreamBatch,
  • closingStreamFutures,
  • ensureClear,
  • ensureNotPoisonPill,
  • ensureOpen,
  • getSizeSignal

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now