summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-07-31 18:34:23 +0200
committerGitHub <noreply@github.com>2018-07-31 18:34:23 +0200
commit0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e (patch)
tree0fe1c843dc51c9563df5b25ade978ac98cb8e18e /src
parentMerge pull request #869 from Subv/ubsan (diff)
parentremove polymorphism issue (diff)
downloadyuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar.gz
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar.bz2
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar.lz
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar.xz
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.tar.zst
yuzu-0a2b219a31b85da3e55b37a040b7e03cb1ccfd3e.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/threadsafe_queue.h32
1 files changed, 30 insertions, 2 deletions
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:
bool Empty() const {
return !read_ptr->next.load();
}
+
T& Front() const {
return read_ptr->current;
}
+
template <typename Arg>
void Push(Arg&& t) {
// create the element, add it to the queue
@@ -108,15 +110,41 @@ private:
// single reader, multiple writer queue
template <typename T, bool NeedSize = true>
-class MPSCQueue : public SPSCQueue<T, NeedSize> {
+class MPSCQueue {
public:
+ u32 Size() const {
+ return spsc_queue.Size();
+ }
+
+ bool Empty() const {
+ return spsc_queue.Empty();
+ }
+
+ T& Front() const {
+ return spsc_queue.Front();
+ }
+
template <typename Arg>
void Push(Arg&& t) {
std::lock_guard<std::mutex> lock(write_lock);
- SPSCQueue<T, NeedSize>::Push(t);
+ spsc_queue.Push(t);
+ }
+
+ void Pop() {
+ return spsc_queue.Pop();
+ }
+
+ bool Pop(T& t) {
+ return spsc_queue.Pop(t);
+ }
+
+ // not thread-safe
+ void Clear() {
+ spsc_queue.Clear();
}
private:
+ SPSCQueue<T, NeedSize> spsc_queue;
std::mutex write_lock;
};
} // namespace Common