From 07c7a405ae20d14e45b9c9bf46c2c4d29d603592 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 23 Oct 2023 15:53:52 +0900 Subject: [PATCH] Fix invalid use of mutex in TSLQueue Mutex was removed in favor of the custom SharedSpinLock. --- src/TSLQueue.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/TSLQueue.hpp b/src/TSLQueue.hpp index 58b468f..76e29d0 100644 --- a/src/TSLQueue.hpp +++ b/src/TSLQueue.hpp @@ -2,7 +2,6 @@ #define UDPC_THREADSAFE_LINKEDLIST_QUEUE_HPP #include -#include #include #include #include @@ -118,9 +117,14 @@ TSLQueue::~TSLQueue() { } template -TSLQueue::TSLQueue(TSLQueue &&other) +TSLQueue::TSLQueue(TSLQueue &&other) : + sharedSpinLock(UDPC::SharedSpinLock::newInstance()), + head(std::shared_ptr(new TSLQNode())), + tail(std::shared_ptr(new TSLQNode())), + msize(0) { - std::lock_guard lock(other.mutex); + auto selfWriteLock = sharedSpinLock->spin_write_lock(); + auto otherWriteLock = other.sharedSpinLock->spin_write_lock(); head = std::move(other.head); tail = std::move(other.tail); msize = std::move(other.msize);