From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A55B3858015; Tue, 20 Sep 2022 14:14:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A55B3858015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663683299; bh=TuSBBrtOe1RjDHbdODEngKF2rHWc+HNCyUpV210f6x8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Cwfh9KVP9pSkgeGenBIQ2DjpJwI5CWjTTMMIR3xzPIu2GaWvQgVop/LLk2x8MWuAv 9U43ZzpF2i8DbE7Tz8hBrKFi8HWB8+1kcm7jzMNEuqMXaK1DitMKaOA6cApEFxZcme /eZBjIqwyUg92fSqikfLQJE630O6Qp+ZvMQUrA4A= From: "rodgertq at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/106772] atomic::wait shouldn't touch waiter pool if used platform wait Date: Tue, 20 Sep 2022 14:14:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rodgertq at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106772 --- Comment #6 from Thomas Rodgers --- (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. >=20 > boost::atomic already do this. >=20 > Why do you cannot make same? (In reply to Mkkt Bkkt from comment #4) > Nice, thanks for benchmarks without code. >=20 > Also, why do I need call notify when don't have wait?=20 >=20 > Common usage from my point of view looks like: >=20 > atomic.wait(value, mo): >=20 > while (atomic.load(mo) =3D=3D value) { > futex_wait(); > } >=20 > Notify want to looks like: >=20 > atomic.store(1, mo) > atomic.notify_one(); >=20 > See: >=20 > https://github.com/lewissbaker/cppcoro/blob/master/lib/ > lightweight_manual_reset_event.cpp >=20 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 >=20 > and others >=20 > So your optimization is pretty useless. >=20 > Also if for some reason possible few notification, or notify before wait, > then possible to have code can looks like: >=20 > if (atomic.exchange(non_wait_value, mo) =3D=3D wait_value) { > atomic.notify_one(); > } I=