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, Iterable<EventExecutor>, Executor, ExecutorService, ScheduledExecutorService
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractEventExecutor
AbstractEventExecutor.LazyRunnable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longWhen time is frozen, the timestamp returned bygetCurrentTimeNanos().private longWhen time is notfrozen, the base time to subtract fromSystem.nanoTime().private booleanWhether time is currently frozen. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidadvanceTimeBy(long nanos) booleanawaitTermination(long timeout, TimeUnit unit) protected voidCancel all scheduled tasks.void(package private) voidprotected longGet the current time in nanoseconds by this executor's clock.(package private) booleanbooleanCallsEventExecutor.inEventLoop(Thread)withThread.currentThread()as argumentbooleaninEventLoop(Thread thread) booleanbooleanReturnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down.booleannext()Returns a reference to itself.(package private) longparent()Return theEventExecutorGroupwhich is the parent of thisEventExecutor,register(ChannelPromise promise) register(Channel channel, ChannelPromise promise) Deprecated.(package private) long(package private) voidrunTasks()voidshutdown()Deprecated.Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) Signals this executor that the caller wants the executor to be shut down.Future<?> Returns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave been terminated.(package private) voidMethods inherited from class AbstractScheduledEventExecutor
afterScheduledTaskSubmitted, beforeScheduledTaskSubmitted, deadlineToDelayNanos, hasScheduledTasks, initialNanoTime, nanoTime, nextScheduledTaskDeadlineNanos, nextScheduledTaskNano, pollScheduledTask, pollScheduledTask, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, validateScheduledMethods inherited from class AbstractEventExecutor
iterator, lazyExecute, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, runTask, safeExecute, shutdownGracefully, shutdownNow, submit, submit, submitMethods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAnyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventExecutor
newFailedFuture, newProgressivePromise, newPromise, newSucceededFutureMethods inherited from interface EventExecutorGroup
iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submitMethods inherited from interface ExecutorService
invokeAll, invokeAll, invokeAny, invokeAnyMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
startTime
private long startTimeWhen time is notfrozen, the base time to subtract fromSystem.nanoTime(). When time is frozen, this variable is unused. Initialized toAbstractScheduledEventExecutor.initialNanoTime()so that until one of the time mutator methods is called,getCurrentTimeNanos()matches the default behavior. -
frozenTimestamp
private long frozenTimestampWhen time is frozen, the timestamp returned bygetCurrentTimeNanos(). When unfrozen, this is unused. -
timeFrozen
private boolean timeFrozenWhether time is currently frozen. -
tasks
-
-
Constructor Details
-
EmbeddedEventLoop
EmbeddedEventLoop()
-
-
Method Details
-
parent
Description copied from interface:EventExecutorReturn theEventExecutorGroupwhich is the parent of thisEventExecutor,- Specified by:
parentin interfaceEventExecutor- Specified by:
parentin interfaceEventLoop- Overrides:
parentin classAbstractEventExecutor
-
next
Description copied from interface:EventExecutorReturns a reference to itself.- Specified by:
nextin interfaceEventExecutor- Specified by:
nextin interfaceEventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Overrides:
nextin classAbstractEventExecutor
-
execute
-
runTasks
void runTasks() -
hasPendingNormalTasks
boolean hasPendingNormalTasks() -
runScheduledTasks
long runScheduledTasks() -
nextScheduledTask
long nextScheduledTask() -
getCurrentTimeNanos
protected long getCurrentTimeNanos()Description copied from class:AbstractScheduledEventExecutorGet the current time in nanoseconds by this executor's clock. This is not the same asSystem.nanoTime()for two reasons:- We apply a fixed offset to the
nanoTime - Implementations (in particular EmbeddedEventLoop) may use their own time source so they can control time for testing purposes.
- Overrides:
getCurrentTimeNanosin classAbstractScheduledEventExecutor
- We apply a fixed offset to the
-
advanceTimeBy
void advanceTimeBy(long nanos) -
freezeTime
void freezeTime() -
unfreezeTime
void unfreezeTime() -
cancelScheduledTasks
protected void cancelScheduledTasks()Description copied from class:AbstractScheduledEventExecutorCancel all scheduled tasks. This method MUST be called only whenAbstractEventExecutor.inEventLoop()istrue.- Overrides:
cancelScheduledTasksin classAbstractScheduledEventExecutor
-
shutdownGracefully
Description copied from interface:EventExecutorGroupSignals 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:
shutdownGracefullyin 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 ofquietPeriodandtimeout- Returns:
- the
EventExecutorGroup.terminationFuture()
-
terminationFuture
Description copied from interface:EventExecutorGroupReturns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave been terminated.- Specified by:
terminationFuturein interfaceEventExecutorGroup
-
shutdown
Deprecated.- Specified by:
shutdownin interfaceEventExecutorGroup- Specified by:
shutdownin interfaceExecutorService- Specified by:
shutdownin classAbstractEventExecutor
-
isShuttingDown
public boolean isShuttingDown()Description copied from interface:EventExecutorGroupReturnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down.- Specified by:
isShuttingDownin interfaceEventExecutorGroup
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService
-
register
Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoop. The returnedChannelFuturewill get notified once the registration was complete.- Specified by:
registerin interfaceEventLoopGroup
-
register
Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoopusing aChannelFuture. The passedChannelFuturewill get notified once the registration was complete and also will get returned.- Specified by:
registerin interfaceEventLoopGroup
-
register
Deprecated.Description copied from interface:EventLoopGroupRegister aChannelwith thisEventLoop. The passedChannelFuturewill get notified once the registration was complete and also will get returned.- Specified by:
registerin interfaceEventLoopGroup
-
inEventLoop
public boolean inEventLoop()Description copied from interface:EventExecutorCallsEventExecutor.inEventLoop(Thread)withThread.currentThread()as argument- Specified by:
inEventLoopin interfaceEventExecutor- Overrides:
inEventLoopin classAbstractEventExecutor
-
inEventLoop
Description copied from interface:EventExecutor- Specified by:
inEventLoopin interfaceEventExecutor
-