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

--- Comment #4 from Mkkt Bkkt <valera.mironow at gmail dot com> ---
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

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();
}

Reply via email to