Class MemoryLimitedTaskQueue<R extends java.lang.Runnable>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.LinkedBlockingQueue<E>
-
- org.apache.shenyu.common.concurrent.MemoryLimitedLinkedBlockingQueue<java.lang.Runnable>
-
- org.apache.shenyu.common.concurrent.MemoryLimitedTaskQueue<R>
-
- 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 theShenyuThreadPoolExecutor. 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 booleandoOffer(java.lang.Runnable runnable)offer element to the queue.EagerExecutorServicegetExecutor()get executor.voidsetExecutor(EagerExecutorService executor)set the executor.-
Methods inherited from class org.apache.shenyu.common.concurrent.MemoryLimitedLinkedBlockingQueue
clear, getCurrentMemory, getCurrentRemainMemory, getMemoryLimit, offer, offer, poll, poll, put, remove, setMemoryLimit, take
-
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.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 org.apache.shenyu.common.concurrent.TaskQueue
offer, retryOffer
-
-
-
-
Method Detail
-
getExecutor
public EagerExecutorService getExecutor()
Description copied from interface:TaskQueueget executor.- Specified by:
getExecutorin interfaceTaskQueue<R extends java.lang.Runnable>- Returns:
- the executor
-
setExecutor
public void setExecutor(EagerExecutorService executor)
Description copied from interface:TaskQueueset the executor.- Specified by:
setExecutorin interfaceTaskQueue<R extends java.lang.Runnable>- Parameters:
executor- executor
-
doOffer
public boolean doOffer(java.lang.Runnable runnable)
Description copied from interface:TaskQueueoffer element to the queue.
-
-