38#if REX_PLATFORM_ANDROID
40REX_API void AndroidInitialize();
45REX_API u32 GetLogicalProcessorCount();
86template <
typename Rep,
typename Period>
87void SleepFor(std::chrono::duration<Rep, Period> duration) {
88 SleepFor(std::chrono::duration_cast<std::chrono::microseconds>(duration));
112template <
typename Rep,
typename Period>
114 return AlertableSleep(std::chrono::duration_cast<std::chrono::microseconds>(duration));
117using TLSHandle = u32;
118constexpr TLSHandle kInvalidTLSHandle = UINT_MAX;
120REX_API TLSHandle AllocateTLSHandle();
122REX_API bool FreeTLSHandle(TLSHandle handle);
134#if REX_PLATFORM_WIN32
137 static const i32 kLowest = -2;
138 static const i32 kBelowNormal = -1;
139 static const i32 kNormal = 0;
140 static const i32 kAboveNormal = 1;
141 static const i32 kHighest = 2;
146 static const i32 kLowest = 1;
147 static const i32 kBelowNormal = 8;
148 static const i32 kNormal = 16;
149 static const i32 kAboveNormal = 24;
150 static const i32 kHighest = 32;
158 size_t stack_size = 4_MiB;
179 static void Exit(
int exit_code);
181 virtual u32 GetSystemID()
const = 0;
183 const std::string& GetName()
const {
return name_; }
186 virtual void SetName(std::string name) { name_ = std::move(name); }
188 virtual i32 GetPriority() = 0;
221 virtual bool Resume(u32* out_previous_suspend_count =
nullptr) = 0;
228 virtual bool Suspend(u32* out_previous_suspend_count =
nullptr) = 0;
264REX_API void RegisterCurrentThread();
281std::jthread
Spawn(std::string_view name, F&& fn) {
282 return std::jthread([thread_name = std::string(name),
283 body = std::forward<F>(fn)](
const std::stop_token& token)
mutable {
284 detail::RegisterCurrentThread();
287 body(std::move(token));
293#if REX_PLATFORM_LINUX || REX_PLATFORM_MAC
294#if REX_PLATFORM_MAC && !defined(_XOPEN_SOURCE)
295#define _XOPEN_SOURCE 700
320 static Fiber*
Create(
size_t stack_size,
void (*entry)(
void*),
void* arg);
337#if REX_PLATFORM_WIN32
338 void* handle_ =
nullptr;
339 bool is_thread_fiber_ =
false;
340#elif REX_PLATFORM_LINUX || REX_PLATFORM_MAC
341 ucontext_t context_{};
342 std::vector<u8> stack_;
343 void (*entry_)(
void*) =
nullptr;
344 void* arg_ =
nullptr;
345 bool is_thread_fiber_ =
false;
347 static void Trampoline();
typename detail::MoveOnlyFunctionFor< Signature >::type MoveOnlyFunction
Definition utility.h:254
Process control, console, environment and crash reports.
Wait objects and wait functions.
Integer types, byte order wrappers and size literals.
Move only function, const propagating pointer and scope guard.