4#include "../Foundation/AlignedStorage.h"
5#include "../Foundation/Function.h"
6#include "../Foundation/Result.h"
7#include "Internal/Optional.h"
12struct ConditionVariable;
47 static constexpr int OpaqueMutexSize = 56 +
sizeof(long);
48 static constexpr int OpaqueMutexAlignment =
alignof(long);
49#elif SC_PLATFORM_WINDOWS
50 static constexpr int OpaqueMutexSize = 4 *
sizeof(
void*) + 2 *
sizeof(
long);
51 static constexpr int OpaqueMutexAlignment =
alignof(
void*);
52#elif SC_PLATFORM_EMSCRIPTEN
53 static constexpr int OpaqueMutexSize =
sizeof(
void*) * 6 +
sizeof(
long);
54 static constexpr int OpaqueMutexAlignment =
alignof(long);
56 static constexpr int OpaqueMutexSize =
sizeof(
void*) * 6;
57 static constexpr int OpaqueMutexAlignment =
alignof(long);
76 void wait(
Mutex& mutex);
82 static constexpr int OpaqueCVSize = 40 +
sizeof(long);
83 static constexpr int OpaqueCVAlignment =
alignof(long);
84#elif SC_PLATFORM_WINDOWS
85 static constexpr int OpaqueCVSize =
sizeof(
void*);
86 static constexpr int OpaqueCVAlignment =
alignof(
void*);
87#elif SC_PLATFORM_EMSCRIPTEN
88 static constexpr int OpaqueCVSize =
sizeof(
void*) * 12;
89 static constexpr int OpaqueCVAlignment =
alignof(long);
91 static constexpr int OpaqueCVSize =
sizeof(
void*) * 6;
92 static constexpr int OpaqueCVAlignment =
alignof(long);
168 UniqueOptional<OpaqueThread> thread;
204 int activeReaders = 0;
205 int waitingWriters = 0;
206 bool writerActive =
false;
238 bool autoReset =
true;
247 bool isSignaled =
false;
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
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
A synchronization point that blocks threads until the required number of threads have reached it.
Definition Threading.h:214
Barrier(uint32_t count)
Creates a barrier that waits for the specified number of threads.
Definition Threading.h:217
void wait()
Wait at the barrier until all threads have reached it.
A native OS condition variable.
Definition Threading.h:66
An automatically reset event object to synchronize two threads.
Definition Threading.h:237
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:19
A native OS mutex to synchronize access to shared resources.
Definition Threading.h:31
A Read-Write lock that allows multiple concurrent readers but only one writer.
Definition Threading.h:177
void lockWrite()
Acquire a write lock. Only one writer can hold the lock, and no readers can hold it simultaneously.
void unlockWrite()
Release a previously acquired write lock.
void lockRead()
Acquire a read lock. Multiple readers can hold the lock concurrently.
void unlockRead()
Release a previously acquired read lock.
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:12
A semaphore synchronization primitive that maintains a count for resource management.
Definition Threading.h:258
void acquire()
Wait for a resource to become available.
void release()
Make a resource available.
Semaphore(int initialCount=0)
Creates a semaphore with an initial count.
A native OS thread.
Definition Threading.h:121
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.