aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Threading/MPSCQueue.h20
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.cpp1
2 files changed, 14 insertions, 7 deletions
diff --git a/src/common/Threading/MPSCQueue.h b/src/common/Threading/MPSCQueue.h
index 91654546298..ee58eb96b29 100644
--- a/src/common/Threading/MPSCQueue.h
+++ b/src/common/Threading/MPSCQueue.h
@@ -18,8 +18,9 @@
#ifndef MPSCQueue_h__
#define MPSCQueue_h__
+#include <array>
#include <atomic>
-#include <type_traits>
+#include <new>
namespace Trinity
{
@@ -92,12 +93,14 @@ private:
template<typename T, std::atomic<T*> T::* IntrusiveLink>
class MPSCQueueIntrusive
{
+ using Atomic = std::atomic<T*>;
+
public:
- MPSCQueueIntrusive() : _dummyPtr(reinterpret_cast<T*>(std::addressof(_dummy))), _head(_dummyPtr), _tail(_dummyPtr)
+ MPSCQueueIntrusive() : _dummyPtr(reinterpret_cast<T*>(_dummy.data())), _head(_dummyPtr), _tail(_dummyPtr)
{
- // _dummy is constructed from aligned_storage and is intentionally left uninitialized (it might not be default constructible)
+ // _dummy is constructed from raw byte array and is intentionally left uninitialized (it might not be default constructible)
// so we init only its IntrusiveLink here
- std::atomic<T*>* dummyNext = new (&(_dummyPtr->*IntrusiveLink)) std::atomic<T*>();
+ Atomic* dummyNext = new (&(_dummyPtr->*IntrusiveLink)) Atomic();
dummyNext->store(nullptr, std::memory_order_relaxed);
}
@@ -106,6 +109,9 @@ public:
T* output;
while (Dequeue(output))
delete output;
+
+ // destruct our dummy atomic
+ (_dummyPtr->*IntrusiveLink).~Atomic();
}
void Enqueue(T* input)
@@ -152,10 +158,10 @@ public:
}
private:
- std::aligned_storage_t<sizeof(T), alignof(T)> _dummy;
+ alignas(T) std::array<std::byte, sizeof(T)> _dummy;
T* _dummyPtr;
- std::atomic<T*> _head;
- std::atomic<T*> _tail;
+ Atomic _head;
+ Atomic _tail;
MPSCQueueIntrusive(MPSCQueueIntrusive const&) = delete;
MPSCQueueIntrusive& operator=(MPSCQueueIntrusive const&) = delete;
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.cpp b/src/server/game/Server/Packets/AuctionHousePackets.cpp
index 4610c0a0111..cc8bdade761 100644
--- a/src/server/game/Server/Packets/AuctionHousePackets.cpp
+++ b/src/server/game/Server/Packets/AuctionHousePackets.cpp
@@ -17,6 +17,7 @@
#include "AuctionHousePackets.h"
#include "AuctionHouseMgr.h"
+#include "DB2Stores.h"
#include "ObjectGuid.h"
#include "Util.h"