[Netty4] [netty-handler] netty the idle handler process

  1. Initialization record idle time, and start a task delay, delay time for the idle time delay task is io.netty.handler.timeout.IdleStateHandler.AllIdleTimeoutTask
  2. channelReadComplete updated lastReadTime, lastWriteTime hung listener is listening operationComplete write operation on the operation returns ChannelFuture instance be updated, see details io.netty.handler.timeout.IdleStateHandler.writeListener
  3. AllIdleTimeoutTask task logic will take lastReadTime, lastWriteTime great value, and take nextDelay subtract them, so that we can get the next task to be postponed and more on the checks performed.

For example, a start is 10: 00,5 minutes idle time, it will check at 10:05 (delay of 5 minutes), if the read and write occur at 10:04, then at 10:05 when calculated in a delayed start checking task 10:09 minutes after 4 minutes.

Timeout reading and writing is done based on this event, similar checking mechanism.
And unused HashedWheelTimer in netty4, but rather online NioEventLoop completed the spin loop trigger. In the spin loop will be out in front (scheduled task is the earliest arriving) from the peek io.netty.util.concurrent.AbstractScheduledEventExecutor.scheduledTaskQueue see its deadline is less than the current time, if it is executed.
HashedWheelTimer idle is used for the detection in netty3.

Guess you like

Origin www.cnblogs.com/simoncook/p/11980435.html