RFR: 8291714: Implement a Multi-Reader Single-Writer mutex for Hotspot
Johan Sjölén
duke at openjdk.org
Wed Aug 24 15:19:37 UTC 2022
On Wed, 17 Aug 2022 13:14:34 GMT, David Holmes <dholmes at openjdk.org> wrote:
>>> > Multi-Reader Single-Writer mutex
>>>
>>> Sorry to bikeshed but such a thing is called a ReadWriteLock or a ReadersWriterLock or something similar - can we please use familiar nomenclature here (even rwlock as per POSIX). "mutex" is a contraction of mutual-exclusion and as readers are not mutually exclusive it is an oxymoron to talk about a "multi-reader mutex". Thanks.
>>
>> For what it's worth, C++ Standard Library uses "mutex" to refer to an object
>> that gets locked, and uses "lock" to refer to an RAII object that locks a
>> "mutex". So it has, for example, `std::shared_mutex`, which is
>> multi-reader/single-writer. The idea being that a "mutex" provides some kind
>> of mutual exclusion - in the case of shared_mutex readers (multiple) are
>> excluded from any writer, and writers are exclusive from each other. I'd
>> prefer that to calling these new things "locks".
>
>> For what it's worth, C++ Standard Library uses "mutex" to refer to an object that gets locked, and uses "lock" to refer to an RAII object that locks a "mutex".
>
> So their "lock" would be our MutexLocker? The far more dominant terminology is that a mutex is a lock.
Thank you for the additional review, @dholmes-ora . I fixed those and added some more documentation.
The changes to `threadHelper.inline.hpp` is being merged through a separate patch (see JDK-8292679, https://github.com/openjdk/jdk/pull/9962), and so are not in need of review.
-------------
PR: https://git.openjdk.org/jdk/pull/9838
More information about the hotspot-runtime-dev
mailing list