[libcxx-commits] [libcxx] [libc++] fix `counting_semaphore` lost wakeups (PR #79265)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 26 09:54:02 PST 2024


================
@@ -95,19 +96,22 @@ public:
     _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
         __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value");
 
-    if (__old > 0) {
-      // Nothing to do
-    } else if (__update > 1)
+    if (__old == 0) {
----------------
ldionne wrote:

Is it possible to still keep the optimization like

```c++
if (__update > 1)
  __a_.notify_all();
else
  __a_.notify_one();
```

https://github.com/llvm/llvm-project/pull/79265


More information about the libcxx-commits mailing list