On Mon, 21 Nov 2022 16:34:46 GMT, Alan Bateman <al...@openjdk.org> wrote:

> > Although this looks much simpler and concise, it means "a new object is 
> > created for each invocation"
> 
> My comment was actually to see if DirectBuffer could extend AutoCloseable so 
> that the acquire returns "this" for the non-session case. Doing the 
> equivalent for the session case might leak into MemorySessionImpl 
> implementing DirectBuffer which you probably don't want to do. If 
> NOP_CLOSE.close can do the Reference.reachabilityFence(this) then it would at 
> least improve some of the use-sites.

Not sure that is simpler. ByteBuffer <: AutoCloseable doesn't seem to make 
sense to me. I'm also not sure how much object allocation (all this stuff will 
become value types) should be the driving factor in these code paths.

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

PR: https://git.openjdk.org/jdk/pull/11260

Reply via email to