Class MPMCBlockingQueue<E>

java.lang.Object
com.conversantmedia.util.concurrent.MPMCConcurrentQueue<E>
com.conversantmedia.util.concurrent.MPMCBlockingQueue<E>
All Implemented Interfaces:
ConcurrentQueue<E>, Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>

public final class MPMCBlockingQueue<E> extends MPMCConcurrentQueue<E> implements Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>, ConcurrentQueue<E>
Alternative implementation for benchmarking purposes
See Also:
  • Field Details

    • queueNotFullCondition

      protected final Condition queueNotFullCondition
    • queueNotEmptyCondition

      protected final Condition queueNotEmptyCondition
  • Constructor Details

    • MPMCBlockingQueue

      public MPMCBlockingQueue(int capacity)

      Construct a blocking queue of the given fixed capacity.

      Note: actual capacity will be the next power of two larger than capacity.
      Parameters:
      capacity - maximum capacity of this queue
    • MPMCBlockingQueue

      public MPMCBlockingQueue(int capacity, SpinPolicy spinPolicy)

      Construct a blocking queue with a given fixed capacity

      Note: actual capacity will be the next power of two larger than capacity. Waiting locking may be used in servers that are tuned for it, waiting locking provides a high performance locking implementation which is approximately a factor of 2 improvement in throughput (40M/s for 1-1 thread transfers) However waiting locking is more CPU aggressive and causes servers that may be configured with far too many threads to show very high load averages. This is probably not as detrimental as it is annoying.
      Parameters:
      capacity - - the queue capacity, suggest using a power of 2
      spinPolicy - - determine the level of cpu aggressiveness in waiting
    • MPMCBlockingQueue

      public MPMCBlockingQueue(int capacity, Collection<? extends E> c)

      Construct a blocking queue of the given fixed capacity

      Note: actual capacity will be the next power of two larger than capacity.

      The values from the collection, c, are appended to the queue in iteration order. If the number of elements in the collection exceeds the actual capacity, then the additional elements overwrite the previous ones until all elements have been written once.
      Parameters:
      capacity - maximum capacity of this queue
      c - A collection to use to populate inital values
  • Method Details