Netty source analysis - closed Services

References: Time Geeks Fu Jian teacher "Netty source code analysis and practical" Talk is cheap.show me the code!

---- lines:

 

 

 

 

 ---- Source:

  And adding the first breakpoint code server modifications: FIG:

 

 

 And then start the server and client; then skip bossGroup to workerGroup; enter workerGroup off: Until then, the first to make a break point at the closed NioEventLoop inside:

Then come to see with closeAll ();

 

 

 Here selectAgain (); canceled purpose is to remove the key, the next key is a valid key. After completing Then go back

 

 

 Into confirmShutdown ();

  

 

 

 Here will run Task and hook; one by one execution is returned:

 

 

 

----to sum up:

    ① closed nature of the service:

      Close all connections and Selector:

    java.nio.channels.Selector#keys

      java.nio.channels.spi.AbstractInterruptibleChannel#close

      java.nio.channels.SelectionKey#cancel

    selector.close();

    Close all thread: exit the loop for (;;).

    ② closed service points:

      Elegant (DEFAULT_ SHUTDOWN_ _QUIET_ PERIOD)

      Controllable (DEFAULT_ SHUTDOWN_ _TIMEOUT)

      To not take live, work was done as far as possible after the hand (first shut off after boss worker: not ensure 100%)

 

I just want to do better, nothing more.

 

Guess you like

Origin www.cnblogs.com/-qilin/p/11821896.html