Wake all waiters on this memory instance (used by Executor::stop()).
| 392 | |
| 393 | /// Wake all waiters on this memory instance (used by Executor::stop()). |
| 394 | void notifyAllWaiters() noexcept { |
| 395 | std::unique_lock<std::mutex> Locker(WaiterMapMutex); |
| 396 | for (auto &[Addr, W] : WaiterMap) { |
| 397 | // Lock the Waiter mutex and notify while holding it. This pairs with |
| 398 | // the wait loop which checks StopToken under this same mutex before |
| 399 | // entering Cond.wait(). The lock ensures we either: |
| 400 | // (a) block until the waiter enters Cond.wait() — then wake it, or |
| 401 | // (b) run before the waiter checks StopToken — it will see it set. |
| 402 | std::unique_lock<std::mutex> WaiterLocker(W.Mutex); |
| 403 | W.Cond.notify_all(); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | private: |
| 408 | /// \name Data of memory instance. |