It seems that the actual close()
implementation is tucked away somewhere in the hierarchy of base classes and implementations of abstract methods. For example, are you guaranteed that the file descriptor gets released? Here is the closest thing to what I wanted to know:
nd.preClose(fd);
long th;
if ((th = readerThread) != 0)
NativeThread.signal(th);
if ((th = writerThread) != 0)
NativeThread.signal(th);
if (!isRegistered())
kill();
from DatagramChannelImpl
. Can anyone translate into English?
So every time I source dive Sun Oracle's Java code I am disappointed. nd as a variable name? Does not get more opaque than that.
What nd is referencing is NativeDispatcher which handles platform specific operations, such as closing File Descriptors (kindly named the variable fd). I can only assume the NativeThread check and signal is to clean up the read/write threads, the source does not lend much information. The isRegistered()
from AbstractSelectableChannel makes sure the Channel is not being used and the kill
method is what closes everything down and finally calls the nd.close(fd);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With