Fix invalid use of mutex in TSLQueue
Mutex was removed in favor of the custom SharedSpinLock.
This commit is contained in:
parent
c798cac80b
commit
4d7f60092e
1 changed files with 7 additions and 3 deletions
|
@ -2,7 +2,6 @@
|
||||||
#define UDPC_THREADSAFE_LINKEDLIST_QUEUE_HPP
|
#define UDPC_THREADSAFE_LINKEDLIST_QUEUE_HPP
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -118,9 +117,14 @@ TSLQueue<T>::~TSLQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
TSLQueue<T>::TSLQueue(TSLQueue &&other)
|
TSLQueue<T>::TSLQueue(TSLQueue &&other) :
|
||||||
|
sharedSpinLock(UDPC::SharedSpinLock::newInstance()),
|
||||||
|
head(std::shared_ptr<TSLQNode>(new TSLQNode())),
|
||||||
|
tail(std::shared_ptr<TSLQNode>(new TSLQNode())),
|
||||||
|
msize(0)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(other.mutex);
|
auto selfWriteLock = sharedSpinLock->spin_write_lock();
|
||||||
|
auto otherWriteLock = other.sharedSpinLock->spin_write_lock();
|
||||||
head = std::move(other.head);
|
head = std::move(other.head);
|
||||||
tail = std::move(other.tail);
|
tail = std::move(other.tail);
|
||||||
msize = std::move(other.msize);
|
msize = std::move(other.msize);
|
||||||
|
|
Loading…
Reference in a new issue