mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
NetPlay: completely redone - should be somewhat usable when using Single Core and DSP LLE Plugin.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5425 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
47
Source/Core/DolphinWX/Src/LockingQueue.h
Normal file
47
Source/Core/DolphinWX/Src/LockingQueue.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef _LOCKINGQUEUE_H_
|
||||
#define _LOCKINGQUEUE_H_
|
||||
|
||||
#include "Thread.h"
|
||||
#include <queue>
|
||||
|
||||
// i should make one of those single reader/ single writer queues
|
||||
|
||||
template <typename T>
|
||||
class LockingQueue
|
||||
{
|
||||
public:
|
||||
size_t Size()
|
||||
{
|
||||
m_crit.Enter();
|
||||
const size_t s = m_queue.size();
|
||||
m_crit.Leave();
|
||||
return s;
|
||||
}
|
||||
|
||||
void Push(const T& t)
|
||||
{
|
||||
m_crit.Enter();
|
||||
m_queue.push(t);
|
||||
m_crit.Leave();
|
||||
}
|
||||
|
||||
bool Pop(T& t)
|
||||
{
|
||||
m_crit.Enter();
|
||||
if (m_queue.size())
|
||||
{
|
||||
t = m_queue.front();
|
||||
m_queue.pop();
|
||||
m_crit.Leave();
|
||||
return true;
|
||||
}
|
||||
m_crit.Leave();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::queue<T> m_queue;
|
||||
Common::CriticalSection m_crit;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user