- TEST_SPEC.md: Updated test directory structure to reflect Core/Asset, Core/IO, and Resources/<Type> subdirectories - TEST_SPEC.md: Updated module names and test counts (852 total) - TEST_SPEC.md: Updated build commands for new Resources subdirectories - README.md: Updated engine structure with Core/Asset/ and Core/IO/ - README.md: Updated Resources section with layered architecture - README.md: Updated test coverage table with accurate counts
44 lines
947 B
C++
44 lines
947 B
C++
#pragma once
|
|
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <XCEngine/Core/Containers/String.h>
|
|
|
|
namespace XCEngine {
|
|
namespace Threading {
|
|
|
|
class Thread {
|
|
public:
|
|
using Id = uint64_t;
|
|
|
|
Thread();
|
|
~Thread();
|
|
|
|
template<typename Func>
|
|
void Start(Func&& func, const Containers::String& name = "Thread");
|
|
void Join();
|
|
void Detach();
|
|
|
|
Id GetId() const { return m_id; }
|
|
const Containers::String& GetName() const { return m_name; }
|
|
|
|
static Id GetCurrentId();
|
|
static void Sleep(uint32_t milliseconds);
|
|
static void Yield();
|
|
|
|
private:
|
|
Id m_id = 0;
|
|
Containers::String m_name;
|
|
std::thread m_thread;
|
|
};
|
|
|
|
template<typename Func>
|
|
void Thread::Start(Func&& func, const Containers::String& name) {
|
|
m_name = name;
|
|
m_thread = std::thread(std::forward<Func>(func));
|
|
m_id = static_cast<Id>(reinterpret_cast<uintptr_t>(m_thread.native_handle()));
|
|
}
|
|
|
|
} // namespace Threading
|
|
} // namespace XCEngine
|