From 0829ef97cac6cb96c49d1401433d9f46639bfeb8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 Feb 2019 22:12:23 -0500 Subject: threadsafe_queue: Use std::size_t for representing size Makes it consistent with the regular standard containers in terms of size representation. This also gets rid of dependence on our own type aliases, removing the need for an include. --- src/common/threadsafe_queue.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index 2660b118a..f553efdc9 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h @@ -7,11 +7,10 @@ // a simple lockless thread-safe, // single reader, single writer queue -#include #include #include #include -#include "common/common_types.h" +#include namespace Common { template @@ -25,7 +24,7 @@ public: delete read_ptr; } - u32 Size() const { + std::size_t Size() const { return size.load(); } @@ -87,7 +86,7 @@ private: // and a pointer to the next ElementPtr class ElementPtr { public: - ElementPtr() : next(nullptr) {} + ElementPtr() {} ~ElementPtr() { ElementPtr* next_ptr = next.load(); @@ -96,12 +95,12 @@ private: } T current; - std::atomic next; + std::atomic next{nullptr}; }; ElementPtr* write_ptr; ElementPtr* read_ptr; - std::atomic size{0}; + std::atomic_size_t size{0}; }; // a simple thread-safe, @@ -110,7 +109,7 @@ private: template class MPSCQueue { public: - u32 Size() const { + std::size_t Size() const { return spsc_queue.Size(); } -- cgit v1.2.3