类 ThreadlessExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.apache.dubbo.common.threadpool.ThreadlessExecutor
-
- 所有已实现的接口:
Executor,ExecutorService
public class ThreadlessExecutor extends AbstractExecutorService
The most important difference between this Executor and other normal Executor is that this one doesn't manage any thread.Tasks submitted to this executor through
execute(Runnable)will not get scheduled to a specific thread, though normal executors always do the schedule. Those tasks are stored in a blocking queue and will only be executed when a thread callswaitAndDrain(), the thread executing the task is exactly the same as the one calling waitAndDrain.
-
-
构造器概要
构造器 构造器 说明 ThreadlessExecutor(ExecutorService sharedExecutor)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanawaitTermination(long timeout, TimeUnit unit)voidexecute(Runnable runnable)If the calling thread is still waiting for a callback task, add the task into the blocking queue to wait for schedule.CompletableFuture<?>getWaitingFuture()booleanisShutdown()booleanisTerminated()booleanisWaiting()voidnotifyReturn(Throwable t)tells the thread blocking onwaitAndDrain()to return, despite of the current status, to avoid endless waiting.voidsetWaitingFuture(CompletableFuture<?> waitingFuture)voidshutdown()The following methods are still not supportedList<Runnable>shutdownNow()voidwaitAndDrain()Waits until there is a task, executes the task and all queued tasks (if there're any).longwaitAndDrain(long timeout, TimeUnit unit)
-
-
-
构造器详细资料
-
ThreadlessExecutor
public ThreadlessExecutor(ExecutorService sharedExecutor)
-
-
方法详细资料
-
getWaitingFuture
public CompletableFuture<?> getWaitingFuture()
-
setWaitingFuture
public void setWaitingFuture(CompletableFuture<?> waitingFuture)
-
isWaiting
public boolean isWaiting()
-
waitAndDrain
public void waitAndDrain() throws InterruptedExceptionWaits until there is a task, executes the task and all queued tasks (if there're any). The task is either a normal response or a timeout response.
-
waitAndDrain
public long waitAndDrain(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
-
execute
public void execute(Runnable runnable)
If the calling thread is still waiting for a callback task, add the task into the blocking queue to wait for schedule. Otherwise, submit to shared callback executor directly.- 参数:
runnable-
-
notifyReturn
public void notifyReturn(Throwable t)
tells the thread blocking onwaitAndDrain()to return, despite of the current status, to avoid endless waiting.
-
shutdown
public void shutdown()
The following methods are still not supported
-
isShutdown
public boolean isShutdown()
-
isTerminated
public boolean isTerminated()
-
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
-
-