RFR: 8255678: Add Mutex::try_lock version without rank checks [v2]
David Holmes
dholmes at openjdk.java.net
Wed Nov 18 22:56:03 UTC 2020
On Wed, 18 Nov 2020 17:54:11 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:
>> I think a different refactoring will be needed here so that:
>> try_lock() -> try_lock_inner(true);
>> try_lock_without_rank_check() -> try_lock_inner(false);
>> try_lock_inner(bool check_rank) { ... }
>> That way code duplication is minimised.
>
> How about just:
> bool Mutex::try_lock() {
> Thread * const self = Thread::current();
> DEBUG_ONLY(if (!owned_by_self()) check_rank(self);)
> return try_lock_inner(self);
> }
> keeping try_lock_without_rank_check() as is. Then I can merge try_lock_inner() with your patch.
If the existing try_lock become try_lock_inner then you are duplicating the owner check. My suggestion minimises code duplication allowing both try_lock and try_lock_without_rank_check to just be simple inline definitions.
My changes just integrated so you can merge now.
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1242
More information about the hotspot-runtime-dev
mailing list