2016-04-17 19:34:47 +00:00
|
|
|
#pragma once
|
2021-04-12 06:34:26 +00:00
|
|
|
#include <stdint.h>
|
2016-04-17 19:34:47 +00:00
|
|
|
|
2022-10-03 08:04:42 +00:00
|
|
|
class CThread
|
2016-04-17 19:34:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-04-28 07:34:09 +00:00
|
|
|
#ifdef _WIN32
|
2022-10-03 08:04:42 +00:00
|
|
|
typedef uint32_t (*CTHREAD_START_ROUTINE)(void * lpThreadParameter);
|
2016-04-28 07:34:09 +00:00
|
|
|
#else
|
2022-10-03 08:04:42 +00:00
|
|
|
typedef void * (*CTHREAD_START_ROUTINE)(void *);
|
2016-04-28 07:34:09 +00:00
|
|
|
#endif
|
2016-04-17 19:34:47 +00:00
|
|
|
CThread(CTHREAD_START_ROUTINE lpStartAddress);
|
|
|
|
~CThread();
|
|
|
|
|
|
|
|
bool Start(void * lpThreadParameter);
|
2022-10-03 08:04:42 +00:00
|
|
|
|
|
|
|
inline uint32_t ThreadID(void) const
|
|
|
|
{
|
|
|
|
return m_threadID;
|
|
|
|
}
|
|
|
|
|
2016-04-17 19:34:47 +00:00
|
|
|
bool isRunning(void) const;
|
|
|
|
void Terminate(void);
|
|
|
|
static uint32_t GetCurrentThreadId(void);
|
|
|
|
|
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CThread(void);
|
2022-10-03 08:04:42 +00:00
|
|
|
CThread(const CThread &);
|
|
|
|
CThread & operator=(const CThread &);
|
2016-04-17 19:34:47 +00:00
|
|
|
|
2022-10-03 08:04:42 +00:00
|
|
|
static void * ThreadWrapper(CThread * _this);
|
2016-04-17 19:34:47 +00:00
|
|
|
|
|
|
|
CTHREAD_START_ROUTINE m_StartAddress;
|
|
|
|
void * m_lpThreadParameter;
|
|
|
|
void * m_thread;
|
|
|
|
uint32_t m_threadID;
|
2016-04-28 07:34:09 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
bool m_running;
|
|
|
|
#endif
|
2021-03-16 23:01:53 +00:00
|
|
|
};
|