#ifndef _MAILBOX_H_ #define _MAILBOX_H_ #include #include #include #include class CMailBox { public: CMailBox(); virtual ~CMailBox(); typedef std::tr1::function FunctionType; void SendCall(const FunctionType&, bool = false); bool IsPending() const; void ReceiveCall(); void WaitForCall(); void WaitForCall(unsigned int); private: struct MESSAGE { FunctionType function; bool sync; }; typedef std::deque FunctionCallQueue; FunctionCallQueue m_calls; boost::mutex m_waitMutex; boost::mutex m_doneNotifyMutex; boost::condition m_callFinished; boost::condition m_waitCondition; bool m_callDone; }; #endif