Codota Logo
QueueFactories.unboundedNonBlockingQueue
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: aol/cyclops

default Topic<T> broadcast(){
  Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
                        .build()
                        .withTimeout(1);
  Topic<T> topic = new Topic<T>(queue,QueueFactories.<T>unboundedNonBlockingQueue());
  AtomicBoolean wip = new AtomicBoolean(false);
  Spliterator<T> split = this.spliterator();
  Continuation ref[] = {null};
  Continuation cont =
      new Continuation(()->{
        if(wip.compareAndSet(false,true)){
          try {
            //use the first consuming thread to tell this Stream onto the Queue
            if(!split.tryAdvance(topic::offer)){
              topic.close();
              return Continuation.empty();
            }
          }finally {
            wip.set(false);
          }
        }
        return ref[0];
      });
  ref[0]=cont;
  queue.addContinuation(cont);
  return topic;
}
origin: aol/cyclops

default <R> R foldParallel(Function<? super Stream<T>,? extends R> fn){
  Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue().build().withTimeout(1);
  AtomicReference<Continuation> ref = new AtomicReference<>(null);
  Continuation cont =
      new Continuation(()->{
        if(ref.get()==null && ref.compareAndSet(null,Continuation.empty())){
          try {
            //use the first consuming thread to tell this Stream onto the Queue
            this.spliterator().forEachRemaining(queue::offer);
          }finally {
            queue.close();
          }
        }
          return Continuation.empty();
        });
  ;
  queue.addContinuation(cont);
  return fn.apply(queue.jdkStream().parallel());
}
default <R> R foldParallel(ForkJoinPool fj,Function<? super Stream<T>,? extends R> fn){
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

public ReactiveSeq<T> changes(){
    com.oath.cyclops.async.adapters.Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
        .build();
    Spliterator<T> copy = copy();
    Continuation[] contRef ={null};
    Signal<T> signal = new Signal<T>(null, queue);
    AtomicBoolean wip = new AtomicBoolean(false);
    Continuation cont = new Continuation(()->{
      if(wip.compareAndSet(false,true)) {
        if(!copy.tryAdvance(signal::set)){
          signal.close();
          return Continuation.empty();
        }
        wip.set(false);
      }
      return contRef[0];
    });
    contRef[0]= cont;
    queue.addContinuation(cont);
    return signal.getDiscrete().stream();
}
origin: aol/cyclops

@Override
public ReactiveSeq<T> changes() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> discrete = QueueFactories.<T>unboundedNonBlockingQueue()
        .build()
        .withTimeout(1);
    Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
        .build();
    Signal<T> signal = new Signal<T>(null, queue);
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

default <R> ReactiveSeq<R> parallel(ForkJoinPool fj,Function<? super Stream<T>,? extends Stream<? extends R>> fn){
  Queue<R> queue = QueueFactories.<R>unboundedNonBlockingQueue()
      .build();
origin: aol/cyclops

default <R> ReactiveSeq<R> parallel(Function<? super Stream<T>,? extends Stream<? extends R>> fn){
  Queue<R> queue = QueueFactories.<R>unboundedNonBlockingQueue()
                               .build();
origin: com.oath.cyclops/cyclops-futurestream

/**
 * This is the default setting, internal queues are backed by a ConcurrentLinkedQueue
 * This operator will return the next stage to using this Queue type if it has been changed
 *
 * @return FutureStream backed by a ConcurrentLinkedQueue
 */
default FutureStream<U> unboundedWaitFree() {
  return this.withQueueFactory(QueueFactories.unboundedNonBlockingQueue());
}
origin: com.oath.cyclops/cyclops-futurestream

<T> Queue<T> createQueue() {
  Queue q;
  if (!backPressureOn)
    q = QueueFactories.unboundedNonBlockingQueue()
             .build();
  else
    q = QueueFactories.boundedQueue(backPressureAfter)
             .build();
  return q;
}
origin: com.oath.cyclops/cyclops-futurestream

public FutureStreamImpl(final LazyReact lazyReact, final Stream<U> stream) {
  this.simpleReact = lazyReact;
  this.lastActive = new LazyStreamWrapper<>(()->
                       stream, lazyReact);
  this.error = new ConsumerHolder(
                  a -> {
                  });
  this.errorHandler = Optional.of((e) -> {
    error.forward.accept(e);
  });
  this.lazyCollector = () -> new BatchingCollector<U>(
                            getMaxActive(), this);
  this.queueFactory = QueueFactories.unboundedNonBlockingQueue();
  this.subscription = new Subscription();
  this.maxActive = lazyReact.getMaxActive();
}
origin: com.oath.cyclops/cyclops-futurestream

public FutureStreamImpl(final LazyReact lazyReact, final Supplier<Stream<U>> stream) {
  this.simpleReact = lazyReact;
  this.lastActive = new LazyStreamWrapper<>((Supplier)stream, lazyReact);
  this.error = new ConsumerHolder(
      a -> {
      });
  this.errorHandler = Optional.of((e) -> {
    error.forward.accept(e);
  });
  this.lazyCollector = () -> new BatchingCollector<U>(
      getMaxActive(), this);
  this.queueFactory = QueueFactories.unboundedNonBlockingQueue();
  this.subscription = new Subscription();
  this.maxActive = lazyReact.getMaxActive();
}
origin: com.oath.cyclops/cyclops

default <R> R foldParallel(Function<? super Stream<T>,? extends R> fn){
  Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue().build().withTimeout(1);
  AtomicReference<Continuation> ref = new AtomicReference<>(null);
  Continuation cont =
      new Continuation(()->{
        if(ref.get()==null && ref.compareAndSet(null,Continuation.empty())){
          try {
            //use the first consuming thread to tell this Stream onto the Queue
            this.spliterator().forEachRemaining(queue::offer);
          }finally {
            queue.close();
          }
        }
          return Continuation.empty();
        });
  ;
  queue.addContinuation(cont);
  return fn.apply(queue.jdkStream().parallel());
}
default <R> R foldParallel(ForkJoinPool fj,Function<? super Stream<T>,? extends R> fn){
origin: com.oath.cyclops/cyclops

default Topic<T> broadcast(){
  Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
                        .build()
                        .withTimeout(1);
  Topic<T> topic = new Topic<T>(queue,QueueFactories.<T>unboundedNonBlockingQueue());
  AtomicBoolean wip = new AtomicBoolean(false);
  Spliterator<T> split = this.spliterator();
  Continuation ref[] = {null};
  Continuation cont =
      new Continuation(()->{
        if(wip.compareAndSet(false,true)){
          try {
            //use the first consuming thread to tell this Stream onto the Queue
            if(!split.tryAdvance(topic::offer)){
              topic.close();
              return Continuation.empty();
            }
          }finally {
            wip.set(false);
          }
        }
        return ref[0];
      });
  ref[0]=cont;
  queue.addContinuation(cont);
  return topic;
}
origin: com.oath.cyclops/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: com.oath.cyclops/cyclops

public ReactiveSeq<T> changes(){
    com.oath.cyclops.async.adapters.Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
        .build();
    Spliterator<T> copy = copy();
    Continuation[] contRef ={null};
    Signal<T> signal = new Signal<T>(null, queue);
    AtomicBoolean wip = new AtomicBoolean(false);
    Continuation cont = new Continuation(()->{
      if(wip.compareAndSet(false,true)) {
        if(!copy.tryAdvance(signal::set)){
          signal.close();
          return Continuation.empty();
        }
        wip.set(false);
      }
      return contRef[0];
    });
    contRef[0]= cont;
    queue.addContinuation(cont);
    return signal.getDiscrete().stream();
}
origin: com.oath.cyclops/cyclops

@Override
public ReactiveSeq<T> changes() {
  if (async == Type.NO_BACKPRESSURE) {
    Queue<T> discrete = QueueFactories.<T>unboundedNonBlockingQueue()
        .build()
        .withTimeout(1);
    Queue<T> queue = QueueFactories.<T>unboundedNonBlockingQueue()
        .build();
    Signal<T> signal = new Signal<T>(null, queue);
origin: com.oath.cyclops/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: com.oath.cyclops/cyclops

default <R> ReactiveSeq<R> parallel(ForkJoinPool fj,Function<? super Stream<T>,? extends Stream<? extends R>> fn){
  Queue<R> queue = QueueFactories.<R>unboundedNonBlockingQueue()
      .build();
origin: com.oath.cyclops/cyclops

default <R> ReactiveSeq<R> parallel(Function<? super Stream<T>,? extends Stream<? extends R>> fn){
  Queue<R> queue = QueueFactories.<R>unboundedNonBlockingQueue()
                               .build();
com.oath.cyclops.asyncQueueFactoriesunboundedNonBlockingQueue

Javadoc

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 & withProducerWaitStrategy methods on the returned queue to change the wait strategy
 
queue.withConsumerWaitStrategy(new DirectWaitStrategy())

Popular methods of QueueFactories

  • boundedNonBlockingQueue
    Generate QueueFactory for bounded non blocking queues. Max queue size is determined by the input par
  • unboundedQueue
    ReactiveSeq.of(1,2,3)
  • boundedQueue
    Create a QueueFactory for boundedQueues where bound is determined by the provided queueSize paramete

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • getExternalFilesDir (Context)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
  • ImageIO (javax.imageio)
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now