Date: Wed, 27 Aug 2025 23:56:33 +0200
Thank you Arthur and Howard!
Sure, I can (re)introduce it. I was given some pretty compelling
arguments for why it should be removed in the first code review I
requested for the implementation:
> https://codereview.stackexchange.com/questions/297876/freestanding-try-lock-for-try-lock-until/297885#297885
The main objection was mainly that it's not predictable (and the
algorithm is an implementation detail) - but I agree that for
consistency and for possible uses of the index that I can't foresee
myself, I'd better add it.
I'll work on an update and be back!
Thanks again,
Ted
2025-08-27, skrev Howard Hinnant:
> 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:
>
> Dining Philosophers Rebooted <https://howardhinnant.github.io/
> dining_philosophers.html>
> howardhinnant.github.io <https://howardhinnant.github.io/
> dining_philosophers.html>
> <https://howardhinnant.github.io/dining_philosophers.html>
>
> <https://howardhinnant.github.io/dining_philosophers.html>
>
>
> llvm-project.png
> llvm-project/libcxx/include/mutex at main · llvm/llvm-project <https://
> github.com/llvm/llvm-project/blob/main/libcxx/include/mutex#L377-L411>
> github.com <https://github.com/llvm/llvm-project/blob/main/libcxx/
> include/mutex#L377-L411>
>
> <https://github.com/llvm/llvm-project/blob/main/libcxx/include/
> mutex#L377-L411>
Sure, I can (re)introduce it. I was given some pretty compelling
arguments for why it should be removed in the first code review I
requested for the implementation:
> https://codereview.stackexchange.com/questions/297876/freestanding-try-lock-for-try-lock-until/297885#297885
The main objection was mainly that it's not predictable (and the
algorithm is an implementation detail) - but I agree that for
consistency and for possible uses of the index that I can't foresee
myself, I'd better add it.
I'll work on an update and be back!
Thanks again,
Ted
2025-08-27, skrev Howard Hinnant:
> 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:
>
> Dining Philosophers Rebooted <https://howardhinnant.github.io/
> dining_philosophers.html>
> howardhinnant.github.io <https://howardhinnant.github.io/
> dining_philosophers.html>
> <https://howardhinnant.github.io/dining_philosophers.html>
>
> <https://howardhinnant.github.io/dining_philosophers.html>
>
>
> llvm-project.png
> llvm-project/libcxx/include/mutex at main · llvm/llvm-project <https://
> github.com/llvm/llvm-project/blob/main/libcxx/include/mutex#L377-L411>
> github.com <https://github.com/llvm/llvm-project/blob/main/libcxx/
> include/mutex#L377-L411>
>
> <https://github.com/llvm/llvm-project/blob/main/libcxx/include/
> mutex#L377-L411>
Received on 2025-08-27 21:56:40