Tabnine Logo
QueueFactories.boundedNonBlockingQueue
Code IndexAdd Tabnine to your IDE (free)

How to use
boundedNonBlockingQueue
method
in
com.oath.cyclops.async.QueueFactories

Best Java code snippets using com.oath.cyclops.async.QueueFactories.boundedNonBlockingQueue (Showing top 9 results out of 315)

origin: aol/cyclops

@Override
public Topic<T> broadcast() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> queue = QueueFactories.<T>boundedNonBlockingQueue(1000)
                    .build()
                    .withTimeout(1);
    Topic<T> topic = new Topic<>(queue, QueueFactories.<T>boundedNonBlockingQueue(1000));
    AtomicBoolean wip = new AtomicBoolean(false);
    return topic;
  Queue<T> queue = QueueFactories.<T>boundedNonBlockingQueue(1000)
                  .build()
                  .withTimeout(1);
  Topic<T> topic = new Topic<>(queue, QueueFactories.<T>boundedNonBlockingQueue(1000));
  AtomicBoolean wip = new AtomicBoolean(false);
  Subscription s = source.subscribe(topic::offer, e -> topic.close(), () -> topic.close());
origin: aol/cyclops

@Test
public void publishToAndMerge(){
  com.oath.cyclops.async.adapters.Queue<Integer> queue = QueueFactories.<Integer>boundedNonBlockingQueue(10)
      .build();
  Thread t=  new Thread( ()-> {
    while(true) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      System.out.println("Closing!");
      queue.close();
    }
  });
  t.start();
  assertThat(Spouts.of(1,2,3)
      .publishTo(queue)
      .peek(System.out::println)
      .merge(queue)
      .toList(), Matchers.equalTo(Arrays.asList(1,1,2,2,3,3)));
}
@Test
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

@Test
public void publishToAndMerge(){
  com.oath.cyclops.async.adapters.Queue<Integer> queue = QueueFactories.<Integer>boundedNonBlockingQueue(10)
                    .build();
  Thread t=  new Thread( ()-> {
    while(true) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
        System.out.println("Closing!");
        queue.close();
    }
  });
  t.start();
  assertThat(ReactiveSeq.of(1,2,3)
             .publishTo(queue)
             .peek(System.out::println)
             .merge(queue)
             .toList(),equalTo(Arrays.asList(1,1,2,2,3,3)));
}
origin: aol/cyclops

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

@Test
public void publishToAndMerge() {
  for (int k = 0; k < ITERATIONS; k++) {
    System.out.println("Publish toNested and zip iteration " + k);
    com.oath.cyclops.async.adapters.Queue<Integer> queue = QueueFactories.<Integer>boundedNonBlockingQueue(10)
        .build();
    Thread t = new Thread(() -> {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      System.out.println("Closing! " + queue.size());
      queue.close();
    });
    t.start();
    AtomicBoolean complete = new AtomicBoolean(false);
    AtomicBoolean start = new AtomicBoolean(false);
    List<Integer> list = of(1, 2, 3)
        .publishTo(queue)
        .peek(System.out::println)
        .merge(queue)
        .toList();
    assertThat(list, hasItems(1, 2, 3));
    assertThat(list.size(), equalTo(6));
    System.gc();
  }
}
origin: aol/cyclops

@Test
public void mergeAdapterTest1() {
  for (int k = 0; k < ITERATIONS; k++) {
    System.out.println("Test iteration " + k);
    Queue<Integer> queue = QueueFactories.<Integer>boundedNonBlockingQueue(10)
        .build();
    Thread t = new Thread(() -> {
      queue.add(1);
      queue.add(2);
      queue.add(3);
      try {
        //    System.out.println("Sleeping!");
        Thread.sleep(10);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      //   System.out.println("Closing! " + queue.size());
      queue.close();
    });
    t.start();
    assertThat(this.<Integer>of(10).peek(i -> System.out.println("publishing " + i))
        .merge(queue).collect(Collectors.toList()), hasItems(10, 1, 2, 3));
    t = null;
    System.gc();
  }
}
origin: com.oath.cyclops/cyclops-futurestream

/**
 * Use an Agrona ManyToOneConcurrentArrayQueue for the next operations (wait-free, mechanical sympathy).
 * Note Queued data will be somewhat limited by configured concurrency level, but that flatMap operations
 * can increase the amount of data to be buffered significantly.
 *
 * <pre>
 * {@code
 *     FutureStream.of(col)
 *                     .boundedWaitFree(110)
 *                     .flatMap(Collection::stream)
 *                     .toList();
 * }
 * </pre>
 *
 * @param size Buffer size
 * @return FutureStream backed by an Agrona ManyToOneConcurrentArrayQueue
 */
default FutureStream<U> boundedWaitFree(final int size) {
  return this.withQueueFactory(QueueFactories.boundedNonBlockingQueue(size));
}
origin: com.oath.cyclops/cyclops

@Override
public Topic<T> broadcast() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> queue = QueueFactories.<T>boundedNonBlockingQueue(1000)
                    .build()
                    .withTimeout(1);
    Topic<T> topic = new Topic<>(queue, QueueFactories.<T>boundedNonBlockingQueue(1000));
    AtomicBoolean wip = new AtomicBoolean(false);
    return topic;
  Queue<T> queue = QueueFactories.<T>boundedNonBlockingQueue(1000)
                  .build()
                  .withTimeout(1);
  Topic<T> topic = new Topic<>(queue, QueueFactories.<T>boundedNonBlockingQueue(1000));
  AtomicBoolean wip = new AtomicBoolean(false);
  Subscription s = source.subscribe(topic::offer, e -> topic.close(), () -> topic.close());
com.oath.cyclops.asyncQueueFactoriesboundedNonBlockingQueue

Javadoc

Creates an async.Queue backed by an Agrona ManyToOneConcurrentArrayQueue bounded by specified queueSize Wait strategy used is NoWaitRetry by default for both Consumers and Producers (both Consumers and Producers will repeatedly retry until successful). Use withConsumerWaitStrategy & withProducerWaitStrategy methods on the returned queue to change the wait strategy
 
queue.withConsumerWaitStrategy(new DirectWaitStrategy())

Popular methods of QueueFactories

  • unboundedQueue
    ReactiveSeq.of(1,2,3)
  • unboundedNonBlockingQueue
    Creates an async.Queue backed by a JDK Wait Free unbounded ConcurrentLinkedQueue The provided WaitSt
  • boundedQueue
    Create a QueueFactory for boundedQueues where bound is determined by the provided queueSize paramete

Popular in Java

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Reference (javax.naming)
  • JLabel (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • From CI to AI: The AI layer in your organization
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