]> git.hungrycats.org Git - bees/commitdiff
Revert "task: wake one Exclusion waiter per release, not all of them"
authorZygo Blaxell <bees@furryterror.org>
Thu, 3 Sep 2026 04:59:49 +0000 (00:59 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 19:00:06 +0000 (15:00 -0400)
This reverts commit 0901597281c3b207ebebd8ea3c4d21ab8bd9bcc8.

lib/task.cc

index 586b46589502dbbddb622a2994057e8f49ae6ea3..495ec845dfa5144a5d0c6020222c2bf864059353 100644 (file)
@@ -1259,7 +1259,7 @@ namespace crucible {
                        // to a replacement owner, that owner's destructor
                        // must not run while we hold m_mutex.
                        shared_ptr<ExclusionOwner> replacement;
-                       Task waiter;
+                       list<Task> waiters;
                        {
                                unique_lock<mutex> lock(m_state->m_mutex);
                                replacement = m_state->m_owner.lock();
@@ -1271,28 +1271,13 @@ namespace crucible {
                                        // will wake the waiters.
                                        return;
                                }
-                               if (m_state->m_waiters.empty()) {
-                                       return;
-                               }
-                               // Wake exactly one waiter.  Waking all of them
-                               // makes every release a broadcast, and the
-                               // broadcasts feed each other: each woken task's
-                               // failed batch reacquire transiently takes and
-                               // releases locks, each such release re-wakes
-                               // every waiter of that lock, and a handful of
-                               // contending tasks can spin this way forever
-                               // (observed as a livelock retrying ~55k/s).
-                               // The woken task retries its whole memoized
-                               // lock set, so locks it acquires and releases
-                               // on the way to failure hand the wake onward;
-                               // the remaining waiters are served one release
-                               // at a time.
-                               waiter = m_state->m_waiters.front();
-                               m_state->m_waiters.pop_front();
+                               waiters.swap(m_state->m_waiters);
                        }
                        // Wake outside the state mutex: Task::run() takes
                        // task-infrastructure locks of its own.
-                       waiter.run();
+                       for (const auto &t : waiters) {
+                               t.run();
+                       }
                }
        };