Tabnine Logo
com.oath.cyclops.async.wait
Code IndexAdd Tabnine to your IDE (free)

How to use com.oath.cyclops.async.wait

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

origin: aol/cyclops

/**
 * @return ExponentialBackofWaitStrategy {@see ExponentialBackofWaitStrategy}
 */
static <T> ExponentialBackofWaitStrategy<T> exponentialBackOff() {
  return new ExponentialBackofWaitStrategy<>();
}
origin: aol/cyclops

@Override
public T take(final com.oath.cyclops.async.wait.WaitStrategy.Takeable<T> t) throws InterruptedException {
  T result;
  while ((result = t.take()) == null) {
  }
  return result;
}
origin: aol/cyclops

  /**
   * @return DirectWaitStrategy {@see DirectWaitStrategy}
   */
  static <T> DirectWaitStrategy<T> direct() {
    return new DirectWaitStrategy<>();
  }
}
origin: aol/cyclops

@Override
public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
  while (!o.offer()) {
  }
  return true;
}
origin: aol/cyclops

/**
 * @return NoWaitRetry strategy {@see NoWaitRetry}
 */
static <T> NoWaitRetry<T> noWaitRetry() {
  return new NoWaitRetry<>();
}
origin: aol/cyclops

/**
 * @return SpinWait strategy {@see SpinWait}
 */
static <T> SpinWait<T> spinWait() {
  return new SpinWait<>();
}
origin: aol/cyclops

/**
 * @return YieldWait strategy {@see YieldWait}
 */
static <T> YieldWait<T> yieldWait() {
  return new YieldWait<>();
}
origin: aol/cyclops

@Override
public T take(final com.oath.cyclops.async.wait.WaitStrategy.Takeable<T> t) throws InterruptedException {
  return t.take();
}
origin: aol/cyclops

@Override
public boolean offer(final com.oath.cyclops.async.wait.WaitStrategy.Offerable o) throws InterruptedException {
  return o.offer();
}
origin: aol/cyclops

/**
 * Creates an async.Queue backed by a JDK Wait Free unbounded ConcurrentLinkedQueue
 * Wait strategy used is NoWaitRetry by default for both Consumers and Producers
 * (both Consumers and Producers will repeatedly retry until successful). Use
 *  withConsumerWaitStrategy &amp; withProducerWaitStrategy methods on the returned queue to change the
 *  wait strategy
 * <pre>
 * {@code
 *    queue.withConsumerWaitStrategy(new DirectWaitStrategy())
 *         .withProducerWaitStrategy(new YieldWait());
 * }</pre>
 *
 *
 * @return Factory for unbounded wait free queue backed by ConcurrentLinkedQueue
 */
public static <T> QueueFactory<T> unboundedNonBlockingQueue() {
  return () -> new Queue<T>(
               new ConcurrentLinkedQueue<>(), new NoWaitRetry<>(), new NoWaitRetry<>());
}
origin: aol/cyclops

/**
 * Queue accepts a BlockingQueue to make use of Blocking semantics
 *
 *
 * @param queue
 *            BlockingQueue to back this Queue
 */
public Queue(final BlockingQueue<T> queue) {
  this(queue, new DirectWaitStrategy<T>(), new DirectWaitStrategy<T>());
}
origin: aol/cyclops

@Override
public T take(final WaitStrategy.Takeable<T> t) throws InterruptedException {
  double currentBackoff = backoffNanos;
  T result;
  while ((result = t.take()) == null) {
    LockSupport.parkNanos((long) currentBackoff);
    currentBackoff = currentBackoff * coefficient;
  }
  return result;
}
origin: aol/cyclops

@Override
public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
  double currentBackoff = backoffNanos;
  while (!o.offer()) {
    LockSupport.parkNanos((long) currentBackoff);
    currentBackoff = currentBackoff * coefficient;
  }
  return true;
}
origin: aol/cyclops

/**
 * 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  &amp; withProducerWaitStrategy methods on the returned queue to change the
 *  wait strategy
 * <pre>
 * {@code
 *    queue.withConsumerWaitStrategy(new DirectWaitStrategy())
 *         .withProducerWaitStrategy(new YieldWait());
 * }</pre>
 *
 * @param queueSize upper bound for Queue
 * @return bounded wait free Queue Factory backed by an Agrona ManyToOneConcurrentArrayQueue
 */
public static <T> QueueFactory<T> boundedNonBlockingQueue(final int queueSize) {
  return () -> new Queue<T>(
               new ManyToOneConcurrentArrayQueue<>(
                                 queueSize),
               new NoWaitRetry<>(), new NoWaitRetry<>());
}
origin: aol/cyclops

Queue(final BlockingQueue<T> queue, final Signal<Integer> sizeSignal) {
  this(queue, new DirectWaitStrategy<T>(), new DirectWaitStrategy<T>());
}
origin: aol/cyclops

@Override
public T take(final WaitStrategy.Takeable<T> t) throws InterruptedException {
  T result;
  while ((result = t.take()) == null) {
    Thread.yield();
  }
  return result;
}
origin: aol/cyclops

@Override
public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
  while (!o.offer()) {
    Thread.yield();
  }
  return true;
}
origin: aol/cyclops

/**
 * Creates an async.Queue backed by an Agrona OneToOneConcurrentArrayQueue 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  &amp; withProducerWaitStrategy methods on the returned queue to change the
 *  wait strategy
 * <pre>
 * {@code
 *    queue.withConsumerWaitStrategy(new DirectWaitStrategy())
 *         .withProducerWaitStrategy(new YieldWait());
 * }</pre>
 *
 * @param queueSize
 * @return
 */
public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize) {
  return () -> new Queue<T>(
               new OneToOneConcurrentArrayQueue<>(
                                 queueSize),
               new NoWaitRetry<>(), new NoWaitRetry<>());
}
/**
origin: aol/cyclops

@Override
public T take(final WaitStrategy.Takeable<T> t) throws InterruptedException {
  T result;
  while ((result = t.take()) == null) {
    LockSupport.parkNanos(1l);
  }
  return result;
}
origin: aol/cyclops

@Override
public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
  while (!o.offer()) {
    LockSupport.parkNanos(1l);
  }
  return true;
}
com.oath.cyclops.async.wait

Most used classes

  • DirectWaitStrategy
    Will try to access the queue once, and return the result directly from the Queue Effectively the sam
  • ExponentialBackofWaitStrategy
    Will recover to recieve or push data to a Queue, backing off by an exponentially increasing wait tim
  • NoWaitRetry
    Repeatedly retry to take or offer element to Queue if full or data unavailable
  • SpinWait
    Repeatedly retry to take or offer element to Queue if full or data unavailable, with a wait of 1 nan
  • WaitStrategy$Offerable
    Represents something that may recieve data
  • WaitStrategy,
  • YieldWait
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