summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-02-12 22:12:23 -0500
committerGravatar Lioncash2019-02-12 22:39:53 -0500
commit0829ef97cac6cb96c49d1401433d9f46639bfeb8 (patch)
tree4001843b442ce4066635537596213a9e16aaefad /src
parentthreadsafe_queue: Remove NeedSize template parameter (diff)
downloadyuzu-0829ef97cac6cb96c49d1401433d9f46639bfeb8.tar.gz
yuzu-0829ef97cac6cb96c49d1401433d9f46639bfeb8.tar.xz
yuzu-0829ef97cac6cb96c49d1401433d9f46639bfeb8.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/common/threadsafe_queue.h13
1 files changed, 6 insertions, 7 deletions
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 @@
7// a simple lockless thread-safe, 7// a simple lockless thread-safe,
8// single reader, single writer queue 8// single reader, single writer queue
9 9
10#include <algorithm>
11#include <atomic> 10#include <atomic>
12#include <cstddef> 11#include <cstddef>
13#include <mutex> 12#include <mutex>
14#include "common/common_types.h" 13#include <utility>
15 14
16namespace Common { 15namespace Common {
17template <typename T> 16template <typename T>
@@ -25,7 +24,7 @@ public:
25 delete read_ptr; 24 delete read_ptr;
26 } 25 }
27 26
28 u32 Size() const { 27 std::size_t Size() const {
29 return size.load(); 28 return size.load();
30 } 29 }
31 30
@@ -87,7 +86,7 @@ private:
87 // and a pointer to the next ElementPtr 86 // and a pointer to the next ElementPtr
88 class ElementPtr { 87 class ElementPtr {
89 public: 88 public:
90 ElementPtr() : next(nullptr) {} 89 ElementPtr() {}
91 ~ElementPtr() { 90 ~ElementPtr() {
92 ElementPtr* next_ptr = next.load(); 91 ElementPtr* next_ptr = next.load();
93 92
@@ -96,12 +95,12 @@ private:
96 } 95 }
97 96
98 T current; 97 T current;
99 std::atomic<ElementPtr*> next; 98 std::atomic<ElementPtr*> next{nullptr};
100 }; 99 };
101 100
102 ElementPtr* write_ptr; 101 ElementPtr* write_ptr;
103 ElementPtr* read_ptr; 102 ElementPtr* read_ptr;
104 std::atomic<u32> size{0}; 103 std::atomic_size_t size{0};
105}; 104};
106 105
107// a simple thread-safe, 106// a simple thread-safe,
@@ -110,7 +109,7 @@ private:
110template <typename T> 109template <typename T>
111class MPSCQueue { 110class MPSCQueue {
112public: 111public:
113 u32 Size() const { 112 std::size_t Size() const {
114 return spsc_queue.Size(); 113 return spsc_queue.Size();
115 } 114 }
116 115