2024-12-06 10:58:55 +00:00
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
2024-12-30 03:44:33 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
#elif defined(GEKKO)
|
2024-12-06 10:58:55 +00:00
|
|
|
#include <ogc/lwp.h>
|
|
|
|
#else
|
|
|
|
#include <threads.h>
|
|
|
|
#endif
|
|
|
|
#include <atomic>
|
|
|
|
namespace Tesses::Framework::Threading
|
|
|
|
{
|
|
|
|
class Thread
|
|
|
|
{
|
2024-12-30 03:44:33 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
|
|
|
|
HANDLE thrd;
|
|
|
|
DWORD thrdId;
|
|
|
|
|
|
|
|
public:
|
|
|
|
#elif defined(GEKKO)
|
2024-12-06 10:58:55 +00:00
|
|
|
lwp_t thrd;
|
|
|
|
static void* cb(void* ptr);
|
|
|
|
#else
|
|
|
|
thrd_t thrd;
|
|
|
|
static int cb(void* ptr);
|
|
|
|
#endif
|
|
|
|
std::function<void()> fn;
|
2024-12-30 03:44:33 +00:00
|
|
|
|
|
|
|
std::atomic<bool> hasInvoked;
|
2024-12-06 10:58:55 +00:00
|
|
|
public:
|
|
|
|
Thread(std::function<void()> fn);
|
|
|
|
void Join();
|
|
|
|
void Detach();
|
|
|
|
};
|
|
|
|
}
|