mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-29 06:07:56 +03:00
33 lines
795 B
C++
33 lines
795 B
C++
#ifndef _MAILBOX_H_
|
|
#define _MAILBOX_H_
|
|
|
|
#include <functional>
|
|
#include <deque>
|
|
#include <boost/thread.hpp>
|
|
|
|
class CMailBox
|
|
{
|
|
public:
|
|
CMailBox();
|
|
virtual ~CMailBox();
|
|
|
|
typedef std::tr1::function<void ()> FunctionType;
|
|
|
|
void SendCall(const FunctionType&, bool = false);
|
|
|
|
bool IsPending() const;
|
|
void ReceiveCall();
|
|
void WaitForCall();
|
|
|
|
private:
|
|
typedef std::deque<FunctionType> FunctionCallQueue;
|
|
|
|
FunctionCallQueue m_calls;
|
|
boost::mutex m_waitMutex;
|
|
boost::mutex m_doneNotifyMutex;
|
|
boost::condition m_callFinished;
|
|
boost::condition m_waitCondition;
|
|
bool m_callDone;
|
|
};
|
|
|
|
#endif
|