From de3b8a47ebb132265db4c38f53f1aeec4385168a Mon Sep 17 00:00:00 2001 From: sladro Date: Mon, 12 Jan 2026 17:58:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=962=EF=BC=8C?= =?UTF-8?q?=E6=9C=89=E5=BE=85=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/utils/spsc_queue.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/utils/spsc_queue.h b/include/utils/spsc_queue.h index 8d76072..dcaeecc 100644 --- a/include/utils/spsc_queue.h +++ b/include/utils/spsc_queue.h @@ -184,6 +184,19 @@ private: struct Cell { std::atomic seq; T data; + + Cell() : seq(0), data() {} + Cell(const Cell&) = delete; + Cell& operator=(const Cell&) = delete; + Cell(Cell&& other) noexcept + : seq(other.seq.load(std::memory_order_relaxed)), data(std::move(other.data)) {} + Cell& operator=(Cell&& other) noexcept { + if (this != &other) { + seq.store(other.seq.load(std::memory_order_relaxed), std::memory_order_relaxed); + data = std::move(other.data); + } + return *this; + } }; // Lock-free bounded MPMC queue (Vyukov). We still expose it as SPSC in this project,