public abstract class SingleThreadEventExecutor extends AbstractExecutorService implements EventExecutor
EventExecutor's that execute all its submitted tasks in a single thread.| Modifier | Constructor and Description |
|---|---|
protected |
SingleThreadEventExecutor(EventExecutorGroup parent,
ThreadFactory threadFactory,
ChannelTaskScheduler scheduler) |
| Modifier and Type | Method and Description |
|---|---|
void |
addShutdownHook(Runnable task) |
protected void |
addTask(Runnable task) |
boolean |
awaitTermination(long timeout,
TimeUnit unit)
Waits until
EventExecutorGroup.isTerminated() returns true or the specified amount of time
passes. |
protected void |
cleanup() |
static SingleThreadEventExecutor |
currentEventLoop() |
void |
execute(Runnable task) |
protected boolean |
hasTasks() |
boolean |
inEventLoop()
Calls
EventExecutor.inEventLoop(Thread) with Thread.currentThread() as argument |
boolean |
inEventLoop(Thread thread)
|
protected void |
interruptThread() |
boolean |
isShutdown()
Returns
true if and only if EventExecutorGroup.shutdown() has been called. |
boolean |
isTerminated()
Returns
true if and only if EventExecutorGroup.shutdown() has been called and all
EventExecutors managed by this group has been terminated completely. |
protected Queue<Runnable> |
newTaskQueue() |
EventExecutor |
next()
Returns a reference to itself.
|
EventExecutorGroup |
parent()
Return the
EventExecutorGroup which is the parent of this EventExecutor,
or null if it has no parent |
protected Runnable |
peekTask() |
protected Runnable |
pollTask() |
void |
removeShutdownHook(Runnable task) |
protected boolean |
removeTask(Runnable task) |
protected abstract void |
run() |
protected boolean |
runAllTasks() |
<V> ScheduledFuture<V> |
schedule(Callable<V> callable,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit) |
void |
shutdown()
Shuts down all
EventExecutors managed by this group. |
List<Runnable> |
shutdownNow() |
protected Runnable |
takeTask() |
protected abstract void |
wakeup(boolean inEventLoop) |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprotected SingleThreadEventExecutor(EventExecutorGroup parent, ThreadFactory threadFactory, ChannelTaskScheduler scheduler)
public static SingleThreadEventExecutor currentEventLoop()
public EventExecutorGroup parent()
EventExecutorEventExecutorGroup which is the parent of this EventExecutor,
or null if it has no parentparent in interface EventExecutorpublic EventExecutor next()
EventExecutornext in interface EventExecutornext in interface EventExecutorGroupprotected void interruptThread()
protected Runnable pollTask()
protected Runnable takeTask() throws InterruptedException
InterruptedExceptionprotected Runnable peekTask()
protected boolean hasTasks()
protected void addTask(Runnable task)
protected boolean removeTask(Runnable task)
protected boolean runAllTasks()
protected abstract void run()
protected void cleanup()
protected abstract void wakeup(boolean inEventLoop)
public boolean inEventLoop()
EventExecutorEventExecutor.inEventLoop(Thread) with Thread.currentThread() as argumentinEventLoop in interface EventExecutorpublic boolean inEventLoop(Thread thread)
EventExecutorinEventLoop in interface EventExecutorpublic void addShutdownHook(Runnable task)
public void removeShutdownHook(Runnable task)
public void shutdown()
EventExecutorGroupEventExecutors managed by this group.shutdown in interface EventExecutorGroupshutdown in interface ExecutorServiceExecutorService.shutdown()public List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
EventExecutorGrouptrue if and only if EventExecutorGroup.shutdown() has been called.isShutdown in interface EventExecutorGroupisShutdown in interface ExecutorServiceExecutorService.isShutdown()public boolean isTerminated()
EventExecutorGrouptrue if and only if EventExecutorGroup.shutdown() has been called and all
EventExecutors managed by this group has been terminated completely.isTerminated in interface EventExecutorGroupisTerminated in interface ExecutorServiceExecutorService.isTerminated()public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
EventExecutorGroupEventExecutorGroup.isTerminated() returns true or the specified amount of time
passes.awaitTermination in interface EventExecutorGroupawaitTermination in interface ExecutorServiceInterruptedExceptionExecutorService.awaitTermination(long, TimeUnit)public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
scheduleAtFixedRate in interface ScheduledExecutorServicepublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
scheduleWithFixedDelay in interface ScheduledExecutorServiceCopyright © 2008-2012 The Netty Project. All Rights Reserved.