Codota Logo
QueueConsumer
Code IndexAdd Codota to your IDE (free)

How to use
QueueConsumer
in
com.obsidiandynamics.nodequeue

Best Java code snippets using com.obsidiandynamics.nodequeue.QueueConsumer (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: com.obsidiandynamics.fulcrum/fulcrum-node-queue

 @Override
 public E next() {
  try {
   return next;
  } finally {
   next = poll();
  }
 }
};
origin: com.obsidiandynamics.fulcrum/fulcrum-node-queue

 public QueueConsumer<E> consumer() {
  return new QueueConsumer<>(tail.get());
 }
}
origin: com.obsidiandynamics.fulcrum/fulcrum-node-queue

 @Override
 public Iterator<E> iterator() {
  return new Iterator<E>() {
   private E next = poll();
   
   @Override
   public boolean hasNext() {
    return next != null;
   }

   @Override
   public E next() {
    try {
     return next;
    } finally {
     next = poll();
    }
   }
  };
 }
}
origin: com.obsidiandynamics.fulcrum/fulcrum-node-queue

public int drain(List<E> sink) {
 int drained = 0;
 for (E item; (item = poll()) != null; sink.add(item), drained++);
 return drained;
}

origin: com.obsidiandynamics.jackdaw/jackdaw-core

private void cycle(WorkerThread t) throws InterruptedException {
 final AsyncRecord<K, V> rec = queueConsumer.poll();
 if (rec != null) {
  sendNow(rec.record, rec.callback);
  yields = 0;
 } else if (yields++ < MAX_YIELDS) {
  Thread.yield();
 } else {
  Thread.sleep(QUEUE_BACKOFF_MILLIS);
 }
}

origin: com.obsidiandynamics.blackstrom/blackstrom-core

private void cycle(WorkerThread thread) throws InterruptedException {
 final Message m = consumer.poll();
 if (m != null) {
  for (MessageHandler handler : handlers) {
   handler.onMessage(context, m);
  }
 } else if (yields++ < maxYields) {
  Thread.yield();
 } else {
  // resetting yields here appears counterintuitive (it makes more sense to reset it on a hit than a miss),
  // however, this technique avoids writing to an instance field from a hotspot, markedly improving performance
  // at the expense of (1) prematurely sleeping on the next miss and (2) yielding after a sleep
  yields = 0;
  Thread.sleep(POLL_BACKOFF_MILLIS);
 }
}

origin: com.obsidiandynamics.blackstrom/blackstrom-core

 @Override
 public void cycle(WorkerThread thread) throws InterruptedException {
  final Message m = consumer.poll();
  if (m != null) {
   if (debugMessageCounts != 0) {
    final long consumed = this.consumed.getAndIncrement();
    if (consumed % debugMessageCounts == 0) {
     logLine.accept(String.format("groupId=%s, consumed=%,d", groupId, consumed));
    }
   }
   
   handler.onMessage(context, m);
  } else if (yields++ < maxYields) {
   Thread.yield();
  } else {
   // resetting yields here appears counterintuitive (it makes more sense to reset it on a hit than a miss);
   // however, this technique avoids writing to an instance field from a hotspot, markedly improving performance
   // at the expense of (1) prematurely sleeping on the next miss and (2) yielding after a sleep
   yields = 0;
   Thread.sleep(POLL_BACKOFF_MILLIS);
  }
 }
}
origin: com.obsidiandynamics.meteor/meteor-core

private void publisherCycle(WorkerThread t) throws InterruptedException {
 List<AsyncRecord> recs = null;
 
 for (;;) {
  final AsyncRecord rec = queueConsumer.poll();
  if (rec != null) {
   if (recs == null) {
    recs = new ArrayList<>();
    yields = 0;
   }
   recs.add(rec);
   if (recs.size() == MAX_BATCH_SIZE) {
    sendNow(recs);
    return;
   }
  } else {
   if (recs != null) {
    sendNow(recs);
   } else if (yields++ < PUBLISH_MAX_YIELDS) {
    Thread.yield();
   } else {
    Thread.sleep(PUBLISH_BACKOFF_MILLIS);
   }
   return;
  }
 }
}

com.obsidiandynamics.nodequeueQueueConsumer

Most used methods

  • poll
  • <init>

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
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