public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: Thomas Rodgers <rodgert@twrodgers.com>,
	Nate Eldredge <nate@thatsmathematics.com>
Subject: Re: [PATCH 1/2] libstdc++: Atomic wait/notify ABI stabilization
Date: Sat, 9 Mar 2024 12:27:19 +0000	[thread overview]
Message-ID: <CACb0b4nyePZzgW7Tt++P6eW+wWZrx3P-khhTXE55KYCH9_P-hA@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4=x1YbFFW7arQAjM5EissFsUwTkXwYPS3CK4MRTykmM4Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]

On Sat, 9 Mar 2024 at 12:18, Jonathan Wakely <jwakely@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	other threads:[~2024-03-09 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 13:45 Jonathan Wakely
2023-11-16 13:45 ` [PATCH 2/2] libstdc++: Pass __wait_args to internal API by const pointer Jonathan Wakely
2023-11-16 20:46 ` [PATCH 1/2] libstdc++: Atomic wait/notify ABI stabilization Jonathan Wakely
2024-03-09 12:18 ` Jonathan Wakely
2024-03-09 12:27   ` Jonathan Wakely [this message]
2023-12-11  8:16 Nate Eldredge
2023-12-11 19:24 ` Nate Eldredge
2023-12-11 20:18   ` Jonathan Wakely
2023-12-14 22:23     ` Thomas Rodgers
2023-12-14 23:30       ` Nate Eldredge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACb0b4nyePZzgW7Tt++P6eW+wWZrx3P-khhTXE55KYCH9_P-hA@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=nate@thatsmathematics.com \
    --cc=rodgert@twrodgers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).