RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v3]
Mark Sheppard
msheppar at openjdk.org
Fri Feb 9 11:18:02 UTC 2024
On Thu, 8 Feb 2024 12:00:44 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> CAS block provides mutual exclusion here, as in, only one thread would ever execute the `freeMemory`/`unreserveMemory` block, which also does not modify any of the fields here. The only (?) thing we might be concerned with is that while one thread is running in the block, another thread would come and bypass the block. If anything relies on memory being actually freed after we exit `run()`, it might subtly misbehave -- accounting code, maybe? I guess a safer way to do this would be acquiring a lock, and checking `invoked` while holding it? Not sure if that is a problem.
>
> The behavior in this PR is now like the intended behavior in Java 21 (and before) but thread-safe. So, by induction, this should be as safe or safer as we had in <= 21. Adding blocking might introduce other problems in a multi-threaded environment.
thanks for the replies, so all invocations lead to Atomic::cmpxchg, where some magic happens....I didn't realise that AtomicInteger is basically a wrapper around what has been added to Deallocator
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17647#discussion_r1484181728
More information about the nio-dev
mailing list