RFR: 8291714: Implement a Multi-Reader Single-Writer mutex for Hotspot [v4]

Johan Sjölén duke at openjdk.org
Fri Aug 26 10:03:58 UTC 2022


On Thu, 25 Aug 2022 16:28:59 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Johan Sjölén has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains six commits:
>> 
>>  - Fix tests for updated threadHelper
>>  - Remove outdated threadHelper
>>  - Update documentation
>>  - Fix outdated headers and remove dead code
>>  - Review comments
>>  - Implement MRSWMutex
>
> src/hotspot/share/utilities/readWriteLock.cpp line 42:
> 
>> 40:           _mon.wait(0);
>> 41:         }
>> 42:       };
> 
> Why is this a lambda rather than a (private) ordinary member function?  There's a bunch of these.  Use of lambda reduces the separation of the code from it's use, but that doesn't seem to me worth the additional clutter.  I'd rather a well-named helper function here, esp. since in this case would be the same helper as used by write_lock.  Call it await_write_unlock.  Consider putting the thread-type handling in the helper too, keeping this function small.

Good point, as it's used twice and has a clear name and purpose it works well as a private member function. I also changed the other lambda into a member function, for symmetry.

> Consider putting the thread-type handling in the helper too, keeping this function small.

To me, it's less surprising to find such handling in the main method.

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

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


More information about the hotspot-dev mailing list