From fcf0a2810ba69d1017d6d7d9a5d6e60ac962f9f1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 27 Mar 2023 16:35:05 +0200 Subject: [PATCH] Added check for cache-alignment to MPSC queue. --- src/mx/util/mpsc_queue.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mx/util/mpsc_queue.h b/src/mx/util/mpsc_queue.h index fe3a022..44c97a2 100644 --- a/src/mx/util/mpsc_queue.h +++ b/src/mx/util/mpsc_queue.h @@ -5,6 +5,8 @@ #include #include #include +#include +#include namespace mx::util { /** @@ -20,6 +22,8 @@ public: : _head(reinterpret_cast(&_stub)), _tail(reinterpret_cast(&_stub)), _end(reinterpret_cast(&_stub)) { + assert((reinterpret_cast(&_head) % 64 == 0) && (reinterpret_cast(&_tail) % 64 == 0) && + "head or tail not cacheline-aligned"); reinterpret_cast(_stub).next(nullptr); } ~MPSCQueue() noexcept = default;