1
0
forked from 0ad/0ad
0ad/source/tools/atlas/GameInterface/MessagePasserImpl.h
Ykkrosh 027c3c7cc0 Use one semaphore for the process's lifetime, for efficiency.
Use a name that works on Linux.
Try several random names to avoid conflicts with other processes.

This was SVN commit r5315.
2007-09-02 21:16:23 +00:00

27 lines
581 B
C++

#include "MessagePasser.h"
#include "ps/ThreadUtil.h"
#include "ps/CStr.h"
#include <queue>
class MessagePasserImpl : public AtlasMessage::MessagePasser, boost::noncopyable
{
public:
MessagePasserImpl();
~MessagePasserImpl();
virtual void Add(AtlasMessage::IMessage* msg);
virtual AtlasMessage::IMessage* Retrieve();
virtual void Query(AtlasMessage::QueryMessage* qry, void(*timeoutCallback)());
bool IsEmpty();
void SetTrace(bool t);
private:
CMutex m_Mutex;
CStr m_SemaphoreName;
sem_t* m_Semaphore;
std::queue<AtlasMessage::IMessage*> m_Queue;
bool m_Trace;
};