Package io.netty.channel.embedded
Class EmbeddedEventLoop
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- io.netty.util.concurrent.AbstractEventExecutor
-
- io.netty.util.concurrent.AbstractScheduledEventExecutor
-
- io.netty.channel.embedded.EmbeddedEventLoop
-
- All Implemented Interfaces:
EventLoop
,EventLoopGroup
,EventExecutor
,EventExecutorGroup
,OrderedEventExecutor
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
final class EmbeddedEventLoop extends AbstractScheduledEventExecutor implements EventLoop
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty.util.concurrent.AbstractEventExecutor
AbstractEventExecutor.LazyRunnable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<java.lang.Runnable>
tasks
-
Constructor Summary
Constructors Constructor Description EmbeddedEventLoop()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
protected void
cancelScheduledTasks()
Cancel all scheduled tasks.void
execute(java.lang.Runnable command)
boolean
inEventLoop()
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argumentboolean
inEventLoop(java.lang.Thread thread)
Returntrue
if the givenThread
is executed in the event loop,false
otherwise.boolean
isShutdown()
boolean
isShuttingDown()
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down.boolean
isTerminated()
EventLoop
next()
Returns a reference to itself.(package private) long
nextScheduledTask()
EventLoopGroup
parent()
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,ChannelFuture
register(Channel channel)
ChannelFuture
register(ChannelPromise promise)
ChannelFuture
register(Channel channel, ChannelPromise promise)
Deprecated.(package private) long
runScheduledTasks()
(package private) void
runTasks()
void
shutdown()
Deprecated.Future<?>
shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
Signals this executor that the caller wants the executor to be shut down.Future<?>
terminationFuture()
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.-
Methods inherited from class io.netty.util.concurrent.AbstractScheduledEventExecutor
afterScheduledTaskSubmitted, beforeScheduledTaskSubmitted, deadlineToDelayNanos, hasScheduledTasks, initialNanoTime, nanoTime, nextScheduledTaskDeadlineNanos, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, validateScheduled
-
Methods inherited from class io.netty.util.concurrent.AbstractEventExecutor
iterator, lazyExecute, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, safeExecute, shutdownGracefully, shutdownNow, submit, submit, submit
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.EventExecutor
newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
-
-
-
-
Method Detail
-
parent
public EventLoopGroup parent()
Description copied from interface:EventExecutor
Return theEventExecutorGroup
which is the parent of thisEventExecutor
,- Specified by:
parent
in interfaceEventExecutor
- Specified by:
parent
in interfaceEventLoop
- Overrides:
parent
in classAbstractEventExecutor
-
next
public EventLoop next()
Description copied from interface:EventExecutor
Returns a reference to itself.- Specified by:
next
in interfaceEventExecutor
- Specified by:
next
in interfaceEventExecutorGroup
- Specified by:
next
in interfaceEventLoopGroup
- Overrides:
next
in classAbstractEventExecutor
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
runTasks
void runTasks()
-
runScheduledTasks
long runScheduledTasks()
-
nextScheduledTask
long nextScheduledTask()
-
cancelScheduledTasks
protected void cancelScheduledTasks()
Description copied from class:AbstractScheduledEventExecutor
Cancel all scheduled tasks. This method MUST be called only whenAbstractEventExecutor.inEventLoop()
istrue
.- Overrides:
cancelScheduledTasks
in classAbstractScheduledEventExecutor
-
shutdownGracefully
public Future<?> shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
Description copied from interface:EventExecutorGroup
Signals this executor that the caller wants the executor to be shut down. Once this method is called,EventExecutorGroup.isShuttingDown()
starts to returntrue
, and the executor prepares to shut itself down. UnlikeEventExecutorGroup.shutdown()
, graceful shutdown ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.- Specified by:
shutdownGracefully
in interfaceEventExecutorGroup
- Parameters:
quietPeriod
- the quiet period as described in the documentationtimeout
- the maximum amount of time to wait until the executor is EventExecutorGroup.shutdown() regardless if a task was submitted during the quiet periodunit
- the unit ofquietPeriod
andtimeout
- Returns:
- the
EventExecutorGroup.terminationFuture()
-
terminationFuture
public Future<?> terminationFuture()
Description copied from interface:EventExecutorGroup
Returns theFuture
which is notified when allEventExecutor
s managed by thisEventExecutorGroup
have been terminated.- Specified by:
terminationFuture
in interfaceEventExecutorGroup
-
shutdown
@Deprecated public void shutdown()
Deprecated.- Specified by:
shutdown
in interfaceEventExecutorGroup
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
- Specified by:
shutdown
in classAbstractEventExecutor
-
isShuttingDown
public boolean isShuttingDown()
Description copied from interface:EventExecutorGroup
Returnstrue
if and only if allEventExecutor
s managed by thisEventExecutorGroup
are being shut down gracefully or was shut down.- Specified by:
isShuttingDown
in interfaceEventExecutorGroup
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
- Specified by:
awaitTermination
in interfacejava.util.concurrent.ExecutorService
-
register
public ChannelFuture register(Channel channel)
Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
. The returnedChannelFuture
will get notified once the registration was complete.- Specified by:
register
in interfaceEventLoopGroup
-
register
public ChannelFuture register(ChannelPromise promise)
Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
using aChannelFuture
. The passedChannelFuture
will get notified once the registration was complete and also will get returned.- Specified by:
register
in interfaceEventLoopGroup
-
register
@Deprecated public ChannelFuture register(Channel channel, ChannelPromise promise)
Deprecated.Description copied from interface:EventLoopGroup
Register aChannel
with thisEventLoop
. The passedChannelFuture
will get notified once the registration was complete and also will get returned.- Specified by:
register
in interfaceEventLoopGroup
-
inEventLoop
public boolean inEventLoop()
Description copied from interface:EventExecutor
CallsEventExecutor.inEventLoop(Thread)
withThread.currentThread()
as argument- Specified by:
inEventLoop
in interfaceEventExecutor
- Overrides:
inEventLoop
in classAbstractEventExecutor
-
inEventLoop
public boolean inEventLoop(java.lang.Thread thread)
Description copied from interface:EventExecutor
Returntrue
if the givenThread
is executed in the event loop,false
otherwise.- Specified by:
inEventLoop
in interfaceEventExecutor
-
-