On Sat, 9 Mar 2024 at 12:18, Jonathan Wakely <jwak...@redhat.com> wrote:

>
>
>
> +    template<typename _Rep, typename _Period>
>> +      __wait_result_type
>> +      __wait_for(const __platform_wait_t* __addr, __wait_args __args,
>> +                const chrono::duration<_Rep, _Period>& __rtime) noexcept
>> +    {
>> +      if (!__rtime.count())
>> +       // no rtime supplied, just spin a bit
>> +       return __detail::__wait_impl(__addr, __args |
>> __wait_flags::__spin_only);
>>
>
> This should set __do_spin | __spin_only if the latter no longer implies
> the former.
>
>
>>
>> +    enum class __wait_flags : uint32_t
>>      {
>>
>
>
>> +       __abi_version = 0,
>> +       __proxy_wait = 1,
>> +       __track_contention = 2,
>> +       __do_spin = 4,
>> +       __spin_only = 8 | __do_spin, // implies __do_spin
>>
>
> This should be just 8 and not also imply __do_spin.
>


Alternatively, we could have:

       __spin_only = 4,
       __spin_then_wait = 8,
       __do_spin = __spin_only | __spin_then_wait,

Then testing (flags & do_spin) would be true if either of the others is
set, but (flags & spin_only) would do the right thing.

But if we have spin_then_wait in the default flags, a caller that wants to
use spin_only has to clear the spin_then_wait flag, otherwise there are two
mutually exclusive flags set at once.

I think I prefer:

       __do_spin = 4,
       __spin_only = 8, // Ignored unless __do_spin is also set.

as this is simpler for callers.

Reply via email to