4#include "../Foundation/AlignedStorage.h"
5#include "../Foundation/Function.h"
6#include "../Foundation/Result.h"
7#include "Internal/Optional.h"
12struct ConditionVariable;
44 static constexpr int OpaqueMutexSize = 56 +
sizeof(long);
45 static constexpr int OpaqueMutexAlignment =
alignof(long);
46#elif SC_PLATFORM_WINDOWS
47 static constexpr int OpaqueMutexSize = 4 *
sizeof(
void*) + 2 *
sizeof(
long);
48 static constexpr int OpaqueMutexAlignment =
alignof(
void*);
49#elif SC_PLATFORM_EMSCRIPTEN
50 static constexpr int OpaqueMutexSize =
sizeof(
void*) * 6 +
sizeof(
long);
51 static constexpr int OpaqueMutexAlignment =
alignof(long);
53 static constexpr int OpaqueMutexSize =
sizeof(
void*) * 6;
54 static constexpr int OpaqueMutexAlignment =
alignof(long);
73 void wait(
Mutex& mutex);
79 static constexpr int OpaqueCVSize = 40 +
sizeof(long);
80 static constexpr int OpaqueCVAlignment =
alignof(long);
81#elif SC_PLATFORM_WINDOWS
82 static constexpr int OpaqueCVSize =
sizeof(
void*);
83 static constexpr int OpaqueCVAlignment =
alignof(
void*);
84#elif SC_PLATFORM_EMSCRIPTEN
85 static constexpr int OpaqueCVSize =
sizeof(
void*) * 12;
86 static constexpr int OpaqueCVAlignment =
alignof(long);
88 static constexpr int OpaqueCVSize =
sizeof(
void*) * 6;
89 static constexpr int OpaqueCVAlignment =
alignof(long);
165 UniqueOptional<OpaqueThread> thread;
175 bool autoReset =
true;
184 bool isSignaled =
false;
char native_char_t
The native char for the platform (wchar_t (4 bytes) on Windows, char (1 byte) everywhere else )
Definition: PrimitiveTypes.h:34
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition: PrimitiveTypes.h:42
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition: PrimitiveTypes.h:38
A native OS condition variable.
Definition: Threading.h:63
An automatically reset event object to synchronize two threads.
Definition: Threading.h:174
void signal()
Unblocks another thread, waiting on EventObject::wait.
void wait()
Waits on a thread for EventObject::signal to be called from another thread.
Wraps function pointers, member functions and lambdas without ever allocating.
Definition: Function.h:50
A native OS mutex to synchronize access to shared resources.
Definition: Threading.h:28
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:12
A native OS thread.
Definition: Threading.h:118
bool wasStarted() const
Check if thread has been started.
static void Sleep(uint32_t milliseconds)
Puts current thread to sleep.
Result start(Function< void(Thread &)> &&func)
Starts the new thread with given name and func.
void setThreadName(const native_char_t *name)
Sets current thread name ONLY if called from inside the thread.
Result detach()
Detaches the thread so that its resources are automatically released back to the system without Threa...
static uint64_t CurrentThreadID()
Returns thread id of the thread calling the function.
uint64_t threadID()
Returns thread id of this thread object (not current thread)
Result join()
Waits for thread to finish and releases its resources.