From e8fcfd9742dbf9d608cf5a5867ea542b9ed9bcac Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Sun, 13 Dec 2020 10:56:59 +0100 Subject: [PATCH] [UnboundedBlockingMpscQueue] Add another assert --- emper/UnboundedBlockingMpscQueue.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emper/UnboundedBlockingMpscQueue.hpp b/emper/UnboundedBlockingMpscQueue.hpp index 81c8a2ff..b9de4631 100644 --- a/emper/UnboundedBlockingMpscQueue.hpp +++ b/emper/UnboundedBlockingMpscQueue.hpp @@ -83,10 +83,16 @@ class UnboundedBlockingMpscQueue : public Blockable<LogSubsystem::U_B_MPSC_Q> { }); if (!tPopped) { std::lock_guard<std::mutex> lock(queueMutex); + // If we observed tPopped to be false without holding the + // queueMutex, then the same must be true when holding the + // mutex. + assert(!tPopped); + // If 't' isn't already set, then mspcQueue.get() MUST // return an element. Note that a non-lineralizabe // queue may break this invariant. assert(!mpscQueue.empty()); + t = mpscQueue.front(); mpscQueue.pop(); postRetrieve(); -- GitLab