RFR: JDK-8320890: [AIX] Find a better way to mimic dl handle equality [v5]
Thomas Stuefe
stuefe at openjdk.org
Mon Dec 18 16:31:43 UTC 2023
On Mon, 18 Dec 2023 11:12:23 GMT, Joachim Kern <jkern at openjdk.org> wrote:
>> src/hotspot/os/aix/porting_aix.cpp line 1097:
>>
>>> 1095: }
>>> 1096:
>>> 1097: pthread_mutex_lock(&g_handletable_mutex);
>>
>> You can make your life a lot easier by defining an RAII object at the start of the file:
>>
>> struct TableLocker {
>> TableLocker() { pthread_mutex_lock(&g_handletable_mutex); }
>> ~TableLocker() { pthread_mutex_unlock(&g_handletable_mutex); }
>> };
>>
>> and just place this at the beginning of your two functions
>>
>> TableLocker lock:
>> ...
>>
>>
>> no need to manually unlock then, with the danger of missing a return.
>
> Great, thank you. This was one of the things I thought about, but was not sure, because I did not fully understood the MutexLocker class and the difference between Monitor and Mutex.
In hindsight, pthread mutex is the better choice anyway: it avoids dependencies to the VM lifecycle (VM mutexes are only available after VM initialization, so we could not call dlopen() before that).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16920#discussion_r1430380082
More information about the hotspot-dev
mailing list