Class KiwiEvictingQueues


  • public class KiwiEvictingQueues
    extends Object
    Utility methods for working with Guava EvictingQueue instances.
    • Constructor Detail

      • KiwiEvictingQueues

        public KiwiEvictingQueues()
    • Method Detail

      • synchronizedEvictingQueue

        public static <T> Queue<T> synchronizedEvictingQueue()
        Create a new, synchronized EvictingQueue that can hold up to DEFAULT_MAX_RECENT_ITEMS items.
        Type Parameters:
        T - the type in the queue
        Returns:
        a synchronized EvictingQueue
        See Also:
        Queues.synchronizedQueue(Queue)
        API Note:
        returns a plain Queue because Guava's Queues.synchronizedQueue(Queue) returns a Queue. Any attempt to cast to an EvictingQueue will result in a ClassCastException.
        Implementation Note:
        See synchronized notes regarding manual synchronization of the returned queue's Iterator in Queues.synchronizedQueue(Queue)
      • synchronizedEvictingQueue

        public static <T> Queue<T> synchronizedEvictingQueue​(int maxSize)
        Create a new, synchronized EvictingQueue that can hold up to maxSize items.
        Type Parameters:
        T - the type in the queue
        Parameters:
        maxSize - maximum size for the queue
        Returns:
        a synchronized EvictingQueue
        See Also:
        Queues.synchronizedQueue(Queue)
        API Note:
        returns a plain Queue because Guava's Queues.synchronizedQueue(Queue) returns a Queue. Any attempt to cast to an EvictingQueue will result in a ClassCastException.
        Implementation Note:
        See synchronized notes regarding manual synchronization of the returned queue's Iterator in Queues.synchronizedQueue(Queue)