RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v4]

Alan Bateman alanb at openjdk.org
Thu Feb 15 19:19:56 UTC 2024


On Thu, 15 Feb 2024 16:58:20 GMT, Mark Sheppard <msheppar at openjdk.org> wrote:

> forget concurrency, forget idempotency, forget safe publication across threads etc. Ask the question what is the Deallocator state representing ... it is encapsulating a native memory address that should be freed by an os::free, and when that has been successfully executed, its state should show that referenced address should no longer be freed, becuse that potential side effects. That's a simple and precise propsition.

FileChannelImpl.Closer, NativeBuffer.Deallocator, and the task returned by DatagramChannelImpl.releaserFor are other examples of cleaning actions in this area. They aren't mutable objects. Instead, they are just functions that run at most once to release the resource.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17647#issuecomment-1947033970


More information about the nio-dev mailing list