Behavior of DatagramChannel vs ByteBuffers bound to MemorySessions

Alan Bateman Alan.Bateman at oracle.com
Sat Jun 8 08:21:53 UTC 2024


On 07/06/2024 18:00, Cleber Muramoto wrote:
> Hello, I'd like to understand why a disconnected DatagramChannel does 
> not support direct buffers derived from MemorySegments created from 
> shared Arenas.
>
>
A shared Arena can be closed at any time. There are safety guarantees 
that go along with that are problematic when doing I/O with byte buffers 
that are backed by a memory segment allocated. For APIs that do 
synchronous I/O then it may be possible to remove this restriction at 
some point. For APIs that do asynchronous I/O (as in initiate an I/O op 
on one thread, complete on another) then it is a harder problem.

-Alan




More information about the nio-dev mailing list