Netty's easy to understand --48.Scalable IO in Java's single-threaded version of the analysis - under (b)

First, explain in detail wakeup, wakeup see the doc source

 For the first selector operation did not return immediately return (this is not how to understand)

If another thread is blocked (long) method call to select () or selec time, it will immediately return calls.

 If the current selection process is not operating, there is a method in the next call will immediately return, unless you also call selectNow ()

If the current is simply no way to call the selection obstruction, then the next method invocation will return immediately.

 

When the call to select () method will be blocked, unless at the same time this method is called again.

In conclusion, it is that wakeup () method can make is under the blocked state can return immediately.

In other words, it is possible after executing the registration configuration information in a timely return selectionKey.

If this state is read is called read () method;

In related events start netty4 extracted as a specific example of the method: active ();

Benefits: After the specific event into a method, we only need enough for this method of programming, we do not need to be judged in here.

 

A simple object model using a state gof

 

Guess you like

Origin blog.csdn.net/qq_37909508/article/details/91353549