2023-07-07 14:00:48 -04:00
|
|
|
#ifndef MXTHREAD_H
|
|
|
|
#define MXTHREAD_H
|
|
|
|
|
2023-07-12 17:12:03 -04:00
|
|
|
#include "compat.h"
|
2023-07-07 14:00:48 -04:00
|
|
|
#include "mxsemaphore.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxtypes.h"
|
2023-07-07 14:00:48 -04:00
|
|
|
|
|
|
|
class MxCore;
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100dc860
|
2023-10-24 19:38:27 -04:00
|
|
|
class MxThread {
|
2023-07-07 14:00:48 -04:00
|
|
|
public:
|
2023-10-24 19:38:27 -04:00
|
|
|
// Note: Comes before virtual destructor
|
|
|
|
virtual MxResult Run();
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-12-13 05:48:14 -05:00
|
|
|
MxResult Start(MxS32 p_stack, MxS32 p_flag);
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void Terminate();
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
void Sleep(MxS32 p_milliseconds);
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
// Inferred, not in DLL
|
|
|
|
inline MxBool IsRunning() { return m_running; }
|
2023-07-07 14:00:48 -04:00
|
|
|
|
|
|
|
protected:
|
2023-10-24 19:38:27 -04:00
|
|
|
MxThread();
|
2023-10-05 03:47:37 -04:00
|
|
|
|
|
|
|
public:
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual ~MxThread();
|
2023-07-07 14:00:48 -04:00
|
|
|
|
|
|
|
private:
|
2023-10-24 19:38:27 -04:00
|
|
|
static unsigned ThreadProc(void* p_thread);
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxULong m_hThread;
|
|
|
|
MxU32 m_threadId;
|
|
|
|
MxBool m_running;
|
|
|
|
MxSemaphore m_semaphore;
|
2023-10-29 10:01:14 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MxCore* m_target;
|
2023-07-07 14:00:48 -04:00
|
|
|
};
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100dc6d8
|
2023-10-24 19:38:27 -04:00
|
|
|
class MxTickleThread : public MxThread {
|
2023-07-07 14:00:48 -04:00
|
|
|
public:
|
2023-12-13 05:48:14 -05:00
|
|
|
MxTickleThread(MxCore* p_target, MxS32 p_frequencyMS);
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
// Only inlined, no offset
|
|
|
|
virtual ~MxTickleThread() {}
|
2023-07-07 14:00:48 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult Run() override;
|
2023-07-07 14:00:48 -04:00
|
|
|
|
|
|
|
private:
|
2023-10-24 19:38:27 -04:00
|
|
|
MxS32 m_frequencyMS;
|
2023-07-07 14:00:48 -04:00
|
|
|
};
|
|
|
|
|
2023-07-12 17:12:03 -04:00
|
|
|
#endif // MXTHREAD_H
|