Class Queues


  • public class Queues
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BUFFER_S  
      static int BUFFER_XS  
      static int TO_LARGE_TO_BE_BOUNDED
      Queues with a requested with a capacity greater than this value are unbounded.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Queue<T> createMpscQueue()
      Creates a new multi-producer single consumer unbounded queue.
      static <T> java.util.Queue<T> createStrictSizeQueue​(int size)
      Create a queue of a strict fixed size.
      static <T> java.util.function.Supplier<java.util.Queue<T>> get​(int bufferSize)
      Gets a supplier to create queues with the given buffer size (size of the array allocated as backend of the queue).
      static <T> java.util.function.Supplier<java.util.Queue<T>> getXsQueueSupplier()  
      static <T> java.util.function.Supplier<java.util.Queue<T>> unbounded​(int size)
      Returns an unbounded Queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TO_LARGE_TO_BE_BOUNDED

        public static final int TO_LARGE_TO_BE_BOUNDED
        Queues with a requested with a capacity greater than this value are unbounded.
        See Also:
        Constant Field Values
      • BUFFER_XS

        public static final int BUFFER_XS
      • BUFFER_S

        public static final int BUFFER_S
    • Method Detail

      • getXsQueueSupplier

        public static <T> java.util.function.Supplier<java.util.Queue<T>> getXsQueueSupplier()
      • get

        public static <T> java.util.function.Supplier<java.util.Queue<T>> get​(int bufferSize)
        Gets a supplier to create queues with the given buffer size (size of the array allocated as backend of the queue).

        The type of the queue and configuration is computed based on the given buffer size.

        Type Parameters:
        T - the type of element
        Parameters:
        bufferSize - the buffer size
        Returns:
        the supplier.
      • unbounded

        public static <T> java.util.function.Supplier<java.util.Queue<T>> unbounded​(int size)
        Returns an unbounded Queue. The queue is array-backed. Each array has the given size. If the queue is full, new arrays can be allocated.
        Type Parameters:
        T - the type of item
        Parameters:
        size - the size of the array
        Returns:
        the unbound queue supplier
      • createMpscQueue

        public static <T> java.util.Queue<T> createMpscQueue()
        Creates a new multi-producer single consumer unbounded queue.
        Type Parameters:
        T - the type of item
        Returns:
        the queue
      • createStrictSizeQueue

        public static <T> java.util.Queue<T> createStrictSizeQueue​(int size)
        Create a queue of a strict fixed size.
        Type Parameters:
        T - the elements type
        Parameters:
        size - the queue size
        Returns:
        a new queue