[libcxx-commits] [PATCH] D114119: [libcxx] Fix potential lost wake-up in counting semaphore

Jan Kokemüller via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 22 13:07:14 PST 2021


jiixyj added a comment.

Wouldn't it also be possible to just unconditionally notify the atomic? Something like this:

  __a.fetch_add(__update, memory_order_release);
  if(__update > 1)
      __a.notify_all();
  else
      __a.notify_one();

One downside is that there might be some unneeded calls to the platform wake function (`futex`, etc.), but it would have the advantage of avoiding thundering herd problems if there are many consumers and a single producer repeatedly calling `notify_one()`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114119/new/

https://reviews.llvm.org/D114119



More information about the libcxx-commits mailing list