From: Stephen Seo Date: Mon, 23 Oct 2023 06:53:52 +0000 (+0900) Subject: Fix invalid use of mutex in TSLQueue X-Git-Tag: 1.0~13 X-Git-Url: https://git.seodisparate.com/js/bootstrap.bundle.min.js?a=commitdiff_plain;h=07c7a405ae20d14e45b9c9bf46c2c4d29d603592;p=UDPConnection Fix invalid use of mutex in TSLQueue Mutex was removed in favor of the custom SharedSpinLock. --- 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);