mirror of
https://github.com/libretro/Play-.git
synced 2024-12-12 11:05:36 +00:00
826e48e8db
git-svn-id: http://svn.purei.org/purei/trunk@1156 b36208d7-6611-0410-8bec-b1987f11c4a2
39 lines
733 B
C++
39 lines
733 B
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <deque>
|
|
#include <mutex>
|
|
#include <condition_variable>
|
|
|
|
class CMailBox
|
|
{
|
|
public:
|
|
CMailBox();
|
|
virtual ~CMailBox();
|
|
|
|
typedef std::function<void ()> FunctionType;
|
|
|
|
void SendCall(const FunctionType&, bool = false);
|
|
void FlushCalls();
|
|
|
|
bool IsPending() const;
|
|
void ReceiveCall();
|
|
void WaitForCall();
|
|
void WaitForCall(unsigned int);
|
|
|
|
private:
|
|
struct MESSAGE
|
|
{
|
|
FunctionType function;
|
|
bool sync;
|
|
};
|
|
|
|
typedef std::deque<MESSAGE> FunctionCallQueue;
|
|
|
|
FunctionCallQueue m_calls;
|
|
std::mutex m_callMutex;
|
|
std::condition_variable m_callFinished;
|
|
std::condition_variable m_waitCondition;
|
|
bool m_callDone;
|
|
};
|