Files
Work/proto/source/PTHREAD.HPP
2024-08-07 09:16:27 -04:00

54 lines
1.1 KiB
C++

#ifndef _PROTO_PROCESSTHREAD_HPP_
#define _PROTO_PROCESSTHREAD_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _THREAD_MESSAGETHREAD_HPP_
#include <thread/mthread.hpp>
#endif
#ifndef _THREAD_EVENT_HPP_
#include <thread/event.hpp>
#endif
class ProcessThread : private MessageThread
{
public:
ProcessThread(void);
virtual ~ProcessThread();
void startProcess(void);
bool isProcessing(void)const;
void waitForProcess(void);
void wait(void);
protected:
virtual void processHandler(void);
private:
enum Message{StartProcess};
ProcessThread(const ProcessThread &someProcessThread);
ProcessThread &operator=(const ProcessThread &someProcessThread);
DWORD threadHandler(ThreadMessage &someThreadMessage);
ThreadCallback<ProcessThread> mThreadHandler;
Event mDestructEvent;
bool mIsProcessing;
};
inline
bool ProcessThread::isProcessing(void)const
{
return mIsProcessing;
}
inline
void ProcessThread::waitForProcess(void)
{
if(!isProcessing())return;
mDestructEvent.waitEvent();
}
inline
void ProcessThread::wait(void)
{
MessageThread::stop();
MessageThread::wait();
}
#endif