RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v3]
Mark Sheppard
msheppar at openjdk.org
Wed Jan 31 18:01:03 UTC 2024
On Wed, 31 Jan 2024 16:44:17 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR proposes to make deallocators and unmappers for memory regions idempotent. This is to prevent (likely very rare) duplicate invocations.
>>
>> There are no unit tests but it should be noted that the idempotent behavior (now correct) is similar to the intended behavior before cf74b8c2a32f33019a13ce80b6667da502cc6722 but where idempotency was not guaranteed in a multi-threaded environment.
>>
>> Passes tier1, 2, and 3 tests.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Swith to using Unsafe
src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 99:
> 97: public void run() {
> 98: // Ensure idempotency (paranoia)
> 99: if (Unsafe.getUnsafe().compareAndSetInt(this, INVOKED_OFFSET, 0, 1)) {
a question for my edification: is this compound statement suitably atomic to ensure synchronzied serial access to freeMemory block ? There's no danger of concurrent interleaved execution resulting in inconsistent view of the member variable via the reflective access ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17647#discussion_r1473240178
More information about the nio-dev
mailing list