72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
#ifndef _THREAD_QUEUETHREAD_HPP_
|
|
#define _THREAD_QUEUETHREAD_HPP_
|
|
#ifndef _THREAD_PURETHREAD_HPP_
|
|
#include <thread/thread.hpp>
|
|
#endif
|
|
#ifndef _THREAD_THREADMESSAGE_HPP_
|
|
#include <thread/thmsg.hpp>
|
|
#endif
|
|
#ifndef _THREAD_MUTEX_HPP_
|
|
#include <thread/mutex.hpp>
|
|
#endif
|
|
#ifndef _THREAD_EVENT_HPP_
|
|
#include <thread/event.hpp>
|
|
#endif
|
|
|
|
class QueueThread : public PureThread
|
|
{
|
|
public:
|
|
QueueThread(void);
|
|
virtual ~QueueThread();
|
|
WORD start(void);
|
|
void stop(void);
|
|
WORD isRunning(void)const;
|
|
protected:
|
|
virtual void startup(void);
|
|
virtual void shutdown(void);
|
|
virtual void messageLoop(void);
|
|
private:
|
|
void startupex(void);
|
|
static DWORD WINAPI sThreadProc(LPVOID lpInstanceData);
|
|
WORD mIsRunning;
|
|
Mutex mQueueThreadDestructorMutex;
|
|
Event mQueueThreadStartupEvent;
|
|
};
|
|
|
|
inline
|
|
QueueThread::QueueThread(void)
|
|
: PureThread(sThreadProc), mIsRunning(FALSE),
|
|
mQueueThreadDestructorMutex("QUEUETHREADDESTRUCTORMUTEX"),
|
|
mQueueThreadStartupEvent("QUEUETHREADSTARTUPEVENT")
|
|
{
|
|
}
|
|
|
|
inline
|
|
QueueThread::~QueueThread()
|
|
{
|
|
mQueueThreadDestructorMutex.requestMutex();
|
|
mQueueThreadDestructorMutex.releaseMutex();
|
|
}
|
|
|
|
inline
|
|
WORD QueueThread::start(void)
|
|
{
|
|
if(!PureThread::start((void*)this))return FALSE;
|
|
if(!(mIsRunning=PureThread::resume()))return FALSE;
|
|
mQueueThreadStartupEvent.waitEvent();
|
|
return mIsRunning;
|
|
}
|
|
|
|
inline
|
|
void QueueThread::stop(void)
|
|
{
|
|
mIsRunning=FALSE;
|
|
}
|
|
|
|
inline
|
|
WORD QueueThread::isRunning(void)const
|
|
{
|
|
return mIsRunning;
|
|
}
|
|
#endif
|