Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following blocking operations are fiber friendly, meaning the fiber will park without pinning the carrier thread when socket is not ready for I/Owhen the operation blocks.

APIMethodsNotes
java.net.Socketread, write, closeRelies on JEP 353
java.net.ServerSocketaccept, close



java.nio.channels.SocketChannelread, write, closesocket adaptor: read, write, and close on the socket adaptor obtained via SocketChannel::socket also okay
java.nio.channels.ServerSocketChannelaccept, closesocket adaptor: accept, closeaccept and close on the socket adpator obtained via ServerSocketChannel::socket also okay
java.nio.channels.DatagramChannelread/, receive, closewrite/send do not block
java.nio.channels.Pipe.SourceChannelread, close
java.nio.channels.Pipe.SinkChannelwrite, close

java.net.Socket

read, write, closejava.net.ServerSocketaccept, close


The following blocking operations are not currently yet fiber friendly; these methods may pin the carrier thread when the socket is not ready for I/O.

niochannels.DatagramChannelreceive
APIMethodsNotes
java.net.socket adaptor: receiveDatagramSocketreceiveNeed to investigate if receive can be done without synchronizing on the DatagramPacket (unspecified but long standing behavior)java.net.DatagramSocket
Thread.interrupt
If a thread is blocked in an I/O operation on an InterruptibleChannel then the channel is closed. The locking to support this is not yet fiber friendly so Thread.interrupt may pin the carrier thread while waiting for the blocking operations on the channel to abort.