NetPlay: completely redone - should be somewhat usable when using Single Core and...
[dolphin.git] / Source / Core / DolphinWX / Src / LockingQueue.h
blob39750916981ea5fea3e8591177f64ddcc39f9a32
1 #ifndef _LOCKINGQUEUE_H_
2 #define _LOCKINGQUEUE_H_
4 #include "Thread.h"
5 #include <queue>
7 // i should make one of those single reader/ single writer queues
9 template <typename T>
10 class LockingQueue
12 public:
13 size_t Size()
15 m_crit.Enter();
16 const size_t s = m_queue.size();
17 m_crit.Leave();
18 return s;
21 void Push(const T& t)
23 m_crit.Enter();
24 m_queue.push(t);
25 m_crit.Leave();
28 bool Pop(T& t)
30 m_crit.Enter();
31 if (m_queue.size())
33 t = m_queue.front();
34 m_queue.pop();
35 m_crit.Leave();
36 return true;
38 m_crit.Leave();
39 return false;
42 private:
43 std::queue<T> m_queue;
44 Common::CriticalSection m_crit;
47 #endif