Class MemoryLimitedTaskQueue<R extends java.lang.Runnable>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.Runnable>, java.util.Collection<java.lang.Runnable>, java.util.concurrent.BlockingQueue<java.lang.Runnable>, java.util.Queue<java.lang.Runnable>, TaskQueue<java.lang.Runnable>

    public class MemoryLimitedTaskQueue<R extends java.lang.Runnable>
    extends MemoryLimitedLinkedBlockingQueue<java.lang.Runnable>
    implements TaskQueue<java.lang.Runnable>
    MemoryLimitedTaskQueue in the ShenyuThreadPoolExecutor. It offer a task if the executor's submittedTaskCount less than currentPoolThreadSize or the currentPoolThreadSize more than executor's maximumPoolSize. That can make the executor create new worker when the task num is bigger than corePoolSize but less than maximumPoolSize.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryLimitedTaskQueue​(long memoryLimit, java.lang.instrument.Instrumentation inst)  
      MemoryLimitedTaskQueue​(java.lang.instrument.Instrumentation inst)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean doOffer​(java.lang.Runnable runnable)
      offer element to the queue.
      EagerExecutorService getExecutor()
      get executor.
      void setExecutor​(EagerExecutorService executor)
      set the executor.
      • Methods inherited from class java.util.concurrent.LinkedBlockingQueue

        contains, drainTo, drainTo, forEach, iterator, peek, remainingCapacity, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
      • Methods inherited from class java.util.AbstractQueue

        add, addAll, element, remove
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.BlockingQueue

        add, contains, drainTo, drainTo, offer, poll, put, remainingCapacity, remove, take
      • Methods inherited from interface java.util.Collection

        addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Queue

        element, peek, poll, remove
    • Constructor Detail

      • MemoryLimitedTaskQueue

        public MemoryLimitedTaskQueue​(java.lang.instrument.Instrumentation inst)
      • MemoryLimitedTaskQueue

        public MemoryLimitedTaskQueue​(long memoryLimit,
                                      java.lang.instrument.Instrumentation inst)
    • Method Detail

      • setExecutor

        public void setExecutor​(EagerExecutorService executor)
        Description copied from interface: TaskQueue
        set the executor.
        Specified by:
        setExecutor in interface TaskQueue<R extends java.lang.Runnable>
        Parameters:
        executor - executor
      • doOffer

        public boolean doOffer​(java.lang.Runnable runnable)
        Description copied from interface: TaskQueue
        offer element to the queue.
        Specified by:
        doOffer in interface TaskQueue<R extends java.lang.Runnable>
        Parameters:
        runnable - the element to add
        Returns:
        true if the element was added to this queue, else false