summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/logging/backend.cpp2
-rw-r--r--src/common/logging/log.h2
-rw-r--r--src/common/threadsafe_queue.h32
3 files changed, 34 insertions, 2 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 55de535c0..d86c40d26 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -171,6 +171,7 @@ void FileBackend::Write(const Entry& entry) {
171 SUB(Service, BCAT) \ 171 SUB(Service, BCAT) \
172 SUB(Service, BTM) \ 172 SUB(Service, BTM) \
173 SUB(Service, Fatal) \ 173 SUB(Service, Fatal) \
174 SUB(Service, FGM) \
174 SUB(Service, Friend) \ 175 SUB(Service, Friend) \
175 SUB(Service, FS) \ 176 SUB(Service, FS) \
176 SUB(Service, HID) \ 177 SUB(Service, HID) \
@@ -185,6 +186,7 @@ void FileBackend::Write(const Entry& entry) {
185 SUB(Service, NIFM) \ 186 SUB(Service, NIFM) \
186 SUB(Service, NS) \ 187 SUB(Service, NS) \
187 SUB(Service, NVDRV) \ 188 SUB(Service, NVDRV) \
189 SUB(Service, PCIE) \
188 SUB(Service, PCTL) \ 190 SUB(Service, PCTL) \
189 SUB(Service, PREPO) \ 191 SUB(Service, PREPO) \
190 SUB(Service, SET) \ 192 SUB(Service, SET) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index e8d98de99..140cd8e47 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -58,6 +58,7 @@ enum class Class : ClassType {
58 Service_BCAT, ///< The BCAT service 58 Service_BCAT, ///< The BCAT service
59 Service_BTM, ///< The BTM service 59 Service_BTM, ///< The BTM service
60 Service_Fatal, ///< The Fatal service 60 Service_Fatal, ///< The Fatal service
61 Service_FGM, ///< The FGM service
61 Service_Friend, ///< The friend service 62 Service_Friend, ///< The friend service
62 Service_FS, ///< The FS (Filesystem) service 63 Service_FS, ///< The FS (Filesystem) service
63 Service_HID, ///< The HID (Human interface device) service 64 Service_HID, ///< The HID (Human interface device) service
@@ -72,6 +73,7 @@ enum class Class : ClassType {
72 Service_NIFM, ///< The NIFM (Network interface) service 73 Service_NIFM, ///< The NIFM (Network interface) service
73 Service_NS, ///< The NS services 74 Service_NS, ///< The NS services
74 Service_NVDRV, ///< The NVDRV (Nvidia driver) service 75 Service_NVDRV, ///< The NVDRV (Nvidia driver) service
76 Service_PCIE, ///< The PCIe service
75 Service_PCTL, ///< The PCTL (Parental control) service 77 Service_PCTL, ///< The PCTL (Parental control) service
76 Service_PREPO, ///< The PREPO (Play report) service 78 Service_PREPO, ///< The PREPO (Play report) service
77 Service_SET, ///< The SET (Settings) service 79 Service_SET, ///< The SET (Settings) service
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index a0c731e8c..edf13bc49 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -33,9 +33,11 @@ public:
33 bool Empty() const { 33 bool Empty() const {
34 return !read_ptr->next.load(); 34 return !read_ptr->next.load();
35 } 35 }
36
36 T& Front() const { 37 T& Front() const {
37 return read_ptr->current; 38 return read_ptr->current;
38 } 39 }
40
39 template <typename Arg> 41 template <typename Arg>
40 void Push(Arg&& t) { 42 void Push(Arg&& t) {
41 // create the element, add it to the queue 43 // create the element, add it to the queue
@@ -108,15 +110,41 @@ private:
108// single reader, multiple writer queue 110// single reader, multiple writer queue
109 111
110template <typename T, bool NeedSize = true> 112template <typename T, bool NeedSize = true>
111class MPSCQueue : public SPSCQueue<T, NeedSize> { 113class MPSCQueue {
112public: 114public:
115 u32 Size() const {
116 return spsc_queue.Size();
117 }
118
119 bool Empty() const {
120 return spsc_queue.Empty();
121 }
122
123 T& Front() const {
124 return spsc_queue.Front();
125 }
126
113 template <typename Arg> 127 template <typename Arg>
114 void Push(Arg&& t) { 128 void Push(Arg&& t) {
115 std::lock_guard<std::mutex> lock(write_lock); 129 std::lock_guard<std::mutex> lock(write_lock);
116 SPSCQueue<T, NeedSize>::Push(t); 130 spsc_queue.Push(t);
131 }
132
133 void Pop() {
134 return spsc_queue.Pop();
135 }
136
137 bool Pop(T& t) {
138 return spsc_queue.Pop(t);
139 }
140
141 // not thread-safe
142 void Clear() {
143 spsc_queue.Clear();
117 } 144 }
118 145
119private: 146private:
147 SPSCQueue<T, NeedSize> spsc_queue;
120 std::mutex write_lock; 148 std::mutex write_lock;
121}; 149};
122} // namespace Common 150} // namespace Common