Date: Wed, 27 Aug 2025 17:34:31 -0400
On Aug 27, 2025, at 5:18 PM, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]> wrote:
>
> Now, if std::try_lock didn't already have this weird int-returning API, I definitely wouldn't be clamoring for you to add it. It seems like a confusing, PHP-style API to me. But since it does exist, I think arguably we should be consistent with it.
>
I agree with your comment.
Motivation for the current try_lock API:
The one use case I had for it needed to identify which try_lock failed in order to implement the “smart & polite” algorithm described here:
https://howardhinnant.github.io/dining_philosophers.html
https://github.com/llvm/llvm-project/blob/main/libcxx/include/mutex#L377-L411
llvm-project/libcxx/include/mutex at main · llvm/llvm-project
github.com
>
> Now, if std::try_lock didn't already have this weird int-returning API, I definitely wouldn't be clamoring for you to add it. It seems like a confusing, PHP-style API to me. But since it does exist, I think arguably we should be consistent with it.
>
I agree with your comment.
Motivation for the current try_lock API:
The one use case I had for it needed to identify which try_lock failed in order to implement the “smart & polite” algorithm described here:
https://howardhinnant.github.io/dining_philosophers.html
https://github.com/llvm/llvm-project/blob/main/libcxx/include/mutex#L377-L411
llvm-project/libcxx/include/mutex at main · llvm/llvm-project
github.com
Received on 2025-08-27 21:35:07