Class JcTools


  • public final class JcTools
    extends java.lang.Object
    Internal accessor of JCTools package for fast queues.

    This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger logger  
      private static java.util.concurrent.atomic.AtomicBoolean queueCreationWarningLogged  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JcTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long capacity​(java.util.Queue<?> queue)
      Returns the capacity of the Queue.
      static <T> void drain​(java.util.Queue<T> queue, int limit, java.util.function.Consumer<T> consumer)
      Remove up to limit elements from the Queue and hand to consume.
      private static <T> void drainNonJcQueue​(java.util.Queue<T> queue, int maxExportBatchSize, java.util.function.Consumer<T> consumer)  
      static <T> java.util.Queue<T> newFixedSizeQueue​(int capacity)
      Returns a new Queue appropriate for use with multiple producers and a single consumer.
      • Methods inherited from class java.lang.Object

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

      • queueCreationWarningLogged

        private static final java.util.concurrent.atomic.AtomicBoolean queueCreationWarningLogged
      • logger

        private static final java.util.logging.Logger logger
    • Constructor Detail

      • JcTools

        private JcTools()
    • Method Detail

      • newFixedSizeQueue

        public static <T> java.util.Queue<T> newFixedSizeQueue​(int capacity)
        Returns a new Queue appropriate for use with multiple producers and a single consumer.
      • capacity

        public static long capacity​(java.util.Queue<?> queue)
        Returns the capacity of the Queue. We cast to the implementation so callers do not need to use the shaded classes.
      • drain

        public static <T> void drain​(java.util.Queue<T> queue,
                                     int limit,
                                     java.util.function.Consumer<T> consumer)
        Remove up to limit elements from the Queue and hand to consume.
        Throws:
        java.lang.IllegalArgumentException - consumer is null
        java.lang.IllegalArgumentException - if maxExportBatchSize is negative
      • drainNonJcQueue

        private static <T> void drainNonJcQueue​(java.util.Queue<T> queue,
                                                int maxExportBatchSize,
                                                java.util.function.Consumer<T> consumer)