Tabnine Logo
LinkedTransferQueue
Code IndexAdd Tabnine to your IDE (free)

How to use
LinkedTransferQueue
in
jsr166y

Best Java code snippets using jsr166y.LinkedTransferQueue (Showing top 20 results out of 315)

origin: h2oai/h2o-2

/**
 * Reconstitutes the Queue instance from a stream (that is,
 * deserializes it).
 *
 * @param s the stream
 */
private void readObject(java.io.ObjectInputStream s)
  throws java.io.IOException, ClassNotFoundException {
  s.defaultReadObject();
  for (;;) {
    @SuppressWarnings("unchecked")
    E item = (E) s.readObject();
    if (item == null)
      break;
    else
      offer(item);
  }
}
origin: h2oai/h2o-2

/**
 * @throws NullPointerException     {@inheritDoc}
 * @throws IllegalArgumentException {@inheritDoc}
 */
public int drainTo(Collection<? super E> c) {
  if (c == null)
    throw new NullPointerException();
  if (c == this)
    throw new IllegalArgumentException();
  int n = 0;
  for (E e; (e = poll()) != null;) {
    c.add(e);
    ++n;
  }
  return n;
}
origin: h2oai/h2o-2

/**
 * Creates a {@code LinkedTransferQueue}
 * initially containing the elements of the given collection,
 * added in traversal order of the collection's iterator.
 *
 * @param c the collection of elements to initially contain
 * @throws NullPointerException if the specified collection or any
 *         of its elements are null
 */
public LinkedTransferQueue(Collection<? extends E> c) {
  this();
  addAll(c);
}
origin: h2oai/h2o-2

/**
 * Returns the item in the first unmatched node with isData; or
 * null if none.  Used by peek.
 */
private E firstDataItem() {
  for (Node p = head; p != null; p = succ(p)) {
    Object item = p.item;
    if (p.isData) {
      if (item != null && item != p)
        return LinkedTransferQueue.<E>cast(item);
    }
    else if (item == null)
      return null;
  }
  return null;
}
origin: h2oai/h2o-2

if (casHead(null, s))
  return s;                 // initialize
  while ((tail != t || !casTail(t, s)) &&
      (t = tail)   != null &&
origin: h2oai/h2o-2

    for (Node q = p; q != h;) {
      if (head == h && casHead(h, n == null ? q : n)) {
        h.forgetNext();
        break;
    return LinkedTransferQueue.<E>cast(item);
if (s == null)
  s = new Node(e, haveData);
Node pred = tryAppend(s, haveData);
if (pred == null)
  continue retry;           // lost race vs opposite mode
if (how != ASYNC)
  return awaitMatch(s, pred, e, (how == TIMED), nanos);
origin: h2oai/h2o-2

if (hn == null)
  return;          // now empty
if (hn != h && casHead(h, hn))
  int v = sweepVotes;
  if (v < SWEEP_THRESHOLD) {
    if (casSweepVotes(v, v + 1))
      break;
  else if (casSweepVotes(v, 0)) {
    sweep();
    break;
origin: h2oai/h2o-2

return LinkedTransferQueue.<E>cast(item);
unsplice(pred, s);
return e;
if ((spins = spinsFor(pred, s.isData)) > 0)
  randomYields = ThreadLocalRandom.current();
origin: h2oai/h2o-2

public int getWaitingConsumerCount() {
  return countOfMode(false);
}
origin: vgrazi/java-concurrent-animated

protected BlockingQueue<ConcurrentSprite> createQueue() {
 return new LinkedTransferQueue<ConcurrentSprite>();
}
origin: org.codehaus.jsr166-mirror/jsr166y

    for (Node q = p; q != h;) {
      if (head == h && casHead(h, n == null ? q : n)) {
        h.forgetNext();
        break;
    return this.<E>cast(item);
if (s == null)
  s = new Node(e, haveData);
Node pred = tryAppend(s, haveData);
if (pred == null)
  continue retry;           // lost race vs opposite mode
if (how != ASYNC)
  return awaitMatch(s, pred, e, (how == TIMED), nanos);
origin: org.codehaus.jsr166-mirror/jsr166y

if (hn == null)
  return;          // now empty
if (hn != h && casHead(h, hn))
  int v = sweepVotes;
  if (v < SWEEP_THRESHOLD) {
    if (casSweepVotes(v, v + 1))
      break;
  else if (casSweepVotes(v, 0)) {
    sweep();
    break;
origin: org.codehaus.jsr166-mirror/jsr166y

return this.<E>cast(item);
unsplice(pred, s);
return e;
if ((spins = spinsFor(pred, s.isData)) > 0)
  randomYields = ThreadLocalRandom.current();
origin: org.codehaus.jsr166-mirror/jsr166y

/**
 * Returns the item in the first unmatched node with isData; or
 * null if none.  Used by peek.
 */
private E firstDataItem() {
  for (Node p = head; p != null; p = succ(p)) {
    Object item = p.item;
    if (p.isData) {
      if (item != null && item != p)
        return this.<E>cast(item);
    }
    else if (item == null)
      return null;
  }
  return null;
}
origin: org.codehaus.jsr166-mirror/jsr166y

if (casHead(null, s))
  return s;                 // initialize
  while ((tail != t || !casTail(t, s)) &&
      (t = tail)   != null &&
origin: h2oai/h2o-2

/**
 * Returns the number of elements in this queue.  If this queue
 * contains more than {@code Integer.MAX_VALUE} elements, returns
 * {@code Integer.MAX_VALUE}.
 *
 * <p>Beware that, unlike in most collections, this method is
 * <em>NOT</em> a constant-time operation. Because of the
 * asynchronous nature of these queues, determining the current
 * number of elements requires an O(n) traversal.
 *
 * @return the number of elements in this queue
 */
public int size() {
  return countOfMode(true);
}
origin: actiontech/dble

public M1() {
  this.x = new LinkedTransferQueue<TransferObject>();
  this.y = new LinkedTransferQueue<TransferObject>();
}
origin: h2oai/h2o-2

/**
 * @throws NullPointerException     {@inheritDoc}
 * @throws IllegalArgumentException {@inheritDoc}
 */
public int drainTo(Collection<? super E> c, int maxElements) {
  if (c == null)
    throw new NullPointerException();
  if (c == this)
    throw new IllegalArgumentException();
  int n = 0;
  for (E e; n < maxElements && (e = poll()) != null;) {
    c.add(e);
    ++n;
  }
  return n;
}
origin: org.codehaus.jsr166-mirror/jsr166y

/**
 * Reconstitutes the Queue instance from a stream (that is,
 * deserializes it).
 *
 * @param s the stream
 */
private void readObject(java.io.ObjectInputStream s)
  throws java.io.IOException, ClassNotFoundException {
  s.defaultReadObject();
  for (;;) {
    @SuppressWarnings("unchecked") E item = (E) s.readObject();
    if (item == null)
      break;
    else
      offer(item);
  }
}
origin: org.codehaus.jsr166-mirror/jsr166y

public int getWaitingConsumerCount() {
  return countOfMode(false);
}
jsr166yLinkedTransferQueue

Javadoc

An unbounded TransferQueue based on linked nodes. This queue orders elements FIFO (first-in-first-out) with respect to any given producer. The head of the queue is that element that has been on the queue the longest time for some producer. The tail of the queue is that element that has been on the queue the shortest time for some producer.

Beware that, unlike in most collections, the size method is NOT a constant-time operation. Because of the asynchronous nature of these queues, determining the current number of elements requires a traversal of the elements, and so may report inaccurate results if this collection is modified during traversal. Additionally, the bulk operations addAll, removeAll, retainAll, containsAll, equals, and toArray are not guaranteed to be performed atomically. For example, an iterator operating concurrently with an addAll operation might view only some of the added elements.

This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces.

Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a LinkedTransferQueuehappen-before actions subsequent to the access or removal of that element from the LinkedTransferQueue in another thread.

This class is a member of the Java Collections Framework.

Most used methods

  • offer
    Inserts the specified element at the tail of this queue. As the queue is unbounded, this method will
  • poll
  • <init>
    Creates a LinkedTransferQueueinitially containing the elements of the given collection, added in tra
  • addAll
  • awaitMatch
    Spins/yields/blocks until node s is matched or caller gives up.
  • casHead
  • casSweepVotes
  • casTail
  • cast
  • countOfMode
    Traverses and counts unmatched nodes of the given mode. Used by methods size and getWaitingConsumerC
  • findAndRemove
    Main implementation of remove(Object)
  • firstDataItem
    Returns the item in the first unmatched node with isData; or null if none. Used by peek.
  • findAndRemove,
  • firstDataItem,
  • firstOfMode,
  • spinsFor,
  • succ,
  • sweep,
  • tryAppend,
  • unsplice,
  • xfer,
  • clear

Popular in Java

  • Updating database using SQL prepared statement
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Top PhpStorm plugins
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