public final class QueuelessExecutor extends java.util.concurrent.AbstractExecutorService implements BlockingExecutorService, BoundedThreadPoolExecutorMBean, ShutdownListenable
| Modifier and Type | Class and Description |
|---|---|
private class |
QueuelessExecutor.Worker |
| Modifier and Type | Field and Description |
|---|---|
private boolean |
blocking
Specify whether this executor blocks when no threads are available.
|
private java.util.concurrent.Executor |
handoffExecutor |
private long |
keepAliveTime
Configuration value.
|
private int |
largestPoolSize |
private java.util.concurrent.locks.Lock |
lock |
private static org.jboss.logging.Logger |
log |
private int |
maxThreads
Configuration value.
|
private java.util.concurrent.locks.Condition |
nextReady |
private int |
rejectedCount |
private java.util.concurrent.locks.Condition |
runnableDequeued |
private java.util.Set<java.lang.Thread> |
runningThreads
Protected by
lock |
private SimpleShutdownListenable |
shutdownListenable |
private boolean |
stop |
private java.util.concurrent.locks.Condition |
taskEnqueued |
private DirectExecutor |
taskExecutor |
private java.util.concurrent.locks.Condition |
threadDeath |
private java.util.concurrent.ThreadFactory |
threadFactory |
private QueuelessExecutor.Worker |
waitingWorker
Protected by
lock, signal workerDequeued on clear |
private java.util.concurrent.locks.Condition |
workerDequeued |
private java.lang.Runnable |
workRunnable
Protected by
lock, signal runnableDequeued on clear |
| Constructor and Description |
|---|
QueuelessExecutor(java.util.concurrent.ThreadFactory threadFactory,
DirectExecutor taskExecutor,
java.util.concurrent.Executor handoffExecutor,
long keepAliveTime) |
| Modifier and Type | Method and Description |
|---|---|
<A> void |
addShutdownListener(EventListener<A> shutdownListener,
A attachment)
Add a shutdown listener.
|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
private static long |
clipHigh(long value) |
void |
execute(java.lang.Runnable task)
Executes the given command at some time in the future.
|
void |
executeBlocking(java.lang.Runnable task)
Execute a task, blocking until it can be accepted, or until the calling thread is interrupted.
|
void |
executeBlocking(java.lang.Runnable task,
long timeout,
java.util.concurrent.TimeUnit unit)
Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.
|
void |
executeNonBlocking(java.lang.Runnable task)
Execute a task, without blocking.
|
int |
getCurrentThreadCount() |
java.util.concurrent.Executor |
getHandoffExecutor() |
long |
getKeepAliveTime() |
int |
getLargestThreadCount() |
int |
getMaxThreads() |
int |
getQueueSize() |
int |
getRejectedCount() |
boolean |
isBlocking() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
setBlocking(boolean blocking) |
void |
setHandoffExecutor(java.util.concurrent.Executor handoffExecutor) |
void |
setKeepAliveTime(long milliseconds) |
void |
setMaxThreads(int newSize) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprivate static final org.jboss.logging.Logger log
private final SimpleShutdownListenable shutdownListenable
private final java.util.concurrent.ThreadFactory threadFactory
private final DirectExecutor taskExecutor
private final java.util.concurrent.locks.Lock lock
private final java.util.concurrent.locks.Condition runnableDequeued
private final java.util.concurrent.locks.Condition nextReady
private final java.util.concurrent.locks.Condition workerDequeued
private final java.util.concurrent.locks.Condition taskEnqueued
private final java.util.concurrent.locks.Condition threadDeath
private final java.util.Set<java.lang.Thread> runningThreads
lockprivate java.lang.Runnable workRunnable
lock, signal runnableDequeued on clearprivate QueuelessExecutor.Worker waitingWorker
lock, signal workerDequeued on clearprivate long keepAliveTime
lockprivate int maxThreads
lockprivate boolean blocking
lockprivate java.util.concurrent.Executor handoffExecutor
private boolean stop
private int largestPoolSize
private int rejectedCount
public QueuelessExecutor(java.util.concurrent.ThreadFactory threadFactory,
DirectExecutor taskExecutor,
java.util.concurrent.Executor handoffExecutor,
long keepAliveTime)
public int getMaxThreads()
getMaxThreads in interface ThreadPoolExecutorMBeanpublic void setMaxThreads(int newSize)
setMaxThreads in interface ThreadPoolExecutorMBeanpublic long getKeepAliveTime()
getKeepAliveTime in interface ThreadPoolExecutorMBeanpublic void setKeepAliveTime(long milliseconds)
setKeepAliveTime in interface ThreadPoolExecutorMBeanpublic int getCurrentThreadCount()
getCurrentThreadCount in interface ThreadExecutorMBeanpublic int getLargestThreadCount()
getLargestThreadCount in interface ThreadExecutorMBeanpublic int getRejectedCount()
getRejectedCount in interface ThreadExecutorMBeanpublic int getQueueSize()
getQueueSize in interface ThreadExecutorMBeanpublic boolean isBlocking()
isBlocking in interface BoundedThreadPoolExecutorMBeanpublic void setBlocking(boolean blocking)
setBlocking in interface BoundedThreadPoolExecutorMBeanpublic java.util.concurrent.Executor getHandoffExecutor()
public void setHandoffExecutor(java.util.concurrent.Executor handoffExecutor)
public void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic void execute(java.lang.Runnable task)
BlockingExecutorexecute in interface java.util.concurrent.Executorexecute in interface BlockingExecutortask - the task to submitpublic void executeBlocking(java.lang.Runnable task)
throws java.util.concurrent.RejectedExecutionException,
java.lang.InterruptedException
BlockingExecutorexecuteBlocking in interface BlockingExecutortask - the task to submitStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonjava.lang.InterruptedException - if the current thread was interrupted before the task could be acceptedpublic void executeBlocking(java.lang.Runnable task,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.util.concurrent.RejectedExecutionException,
java.lang.InterruptedException
BlockingExecutorexecuteBlocking in interface BlockingExecutortask - the task to submittimeout - the amount of time to waitunit - the unit of timeExecutionTimedOutException - if the timeout elapsed before a task could be acceptedStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonjava.lang.InterruptedException - if the current thread was interrupted before the task could be acceptedpublic void executeNonBlocking(java.lang.Runnable task)
throws java.util.concurrent.RejectedExecutionException
BlockingExecutorexecuteNonBlocking in interface BlockingExecutortask - the task to submitStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonpublic <A> void addShutdownListener(EventListener<A> shutdownListener, A attachment)
addShutdownListener in interface ShutdownListenableA - the attachment typeshutdownListener - the listenerattachment - the attachment value to pass to the listenerprivate static long clipHigh(long value)