public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rodgertq at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/106772] atomic<T>::wait shouldn't touch waiter pool if used platform wait
Date: Tue, 20 Sep 2022 14:14:58 +0000	[thread overview]
Message-ID: <bug-106772-4-cBWpFOrWNE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106772-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106772

--- Comment #6 from Thomas Rodgers <rodgertq at gcc dot gnu.org> ---
(In reply to Mkkt Bkkt from comment #5)
> Single reason why I want to use atomic::wait/notify is cross platform api
> for futex, wait/wake on address, ulock, etc
> Not because I need YOU decide instead of me how many spins, or other
> optimization I need.
> 
> boost::atomic already do this.
> 
> Why do you cannot make same?

(In reply to Mkkt Bkkt from comment #4)
> Nice, thanks for benchmarks without code.
> 
> Also, why do I need call notify when don't have wait? 
> 
> Common usage from my point of view looks like:
> 
> atomic.wait(value, mo):
> 
> while (atomic.load(mo) == value) {
>   futex_wait();
> }
> 
> Notify want to looks like:
> 
> atomic.store(1, mo)
> atomic.notify_one();
> 
> See:
> 
> https://github.com/lewissbaker/cppcoro/blob/master/lib/
> lightweight_manual_reset_event.cpp
> 

I have every confidence that Lewis knows how to bring a paper for a
'lightweight manual reset event' to SG1, I suspect it will be well received
when he does.

> https://github.com/YACLib/YACLib/blob/main/src/util/atomic_event.cpp
> 
> and others
> 
> So your optimization is pretty useless.
> 
> Also if for some reason possible few notification, or notify before wait,
> then possible to have code can looks like:
> 
> if (atomic.exchange(non_wait_value, mo) == wait_value) {
>   atomic.notify_one();
> }

I

  parent reply	other threads:[~2022-09-20 14:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 12:38 [Bug libstdc++/106772] New: " valera.mironow at gmail dot com
2022-08-29 12:40 ` [Bug libstdc++/106772] " valera.mironow at gmail dot com
2022-08-29 15:12 ` rodgertq at gcc dot gnu.org
2022-09-20  3:38 ` rodgertq at gcc dot gnu.org
2022-09-20  7:39 ` valera.mironow at gmail dot com
2022-09-20  7:47 ` valera.mironow at gmail dot com
2022-09-20 14:14 ` rodgertq at gcc dot gnu.org [this message]
2022-09-20 14:20 ` valera.mironow at gmail dot com
2022-09-20 14:23 ` valera.mironow at gmail dot com
2022-09-20 14:27 ` valera.mironow at gmail dot com
2022-09-20 14:36 ` redi at gcc dot gnu.org
2022-09-20 14:40 ` rodgertq at gcc dot gnu.org
2022-09-20 14:54 ` valera.mironow at gmail dot com
2022-09-20 15:45 ` valera.mironow at gmail dot com
2022-09-20 15:55 ` redi at gcc dot gnu.org
2022-09-20 16:00 ` valera.mironow at gmail dot com
2022-09-20 16:05 ` valera.mironow at gmail dot com
2022-09-28 21:54 ` rodgertq at gcc dot gnu.org
2022-09-28 22:00 ` valera.mironow at gmail dot com
2022-09-28 22:04 ` valera.mironow at gmail dot com
2022-09-28 22:18 ` valera.mironow at gmail dot com
2022-09-28 22:34 ` rodgertq at gcc dot gnu.org
2022-09-28 22:50 ` rodgertq at gcc dot gnu.org
2022-09-28 23:09 ` valera.mironow at gmail dot com
2022-09-28 23:25 ` valera.mironow at gmail dot com
2022-09-28 23:40 ` rodgertq at gcc dot gnu.org

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=bug-106772-4-cBWpFOrWNE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).