Thread management and synchronization methods
Types
-
This\ type\ is\ thread\ safe. Represents a system-level mutex object.
-
A RAII wrapper for one mutex object that releases the mutex automatically when the wrapper is destructed.
-
Represents one system-level read write lock.
-
Represents one system-level semaphore object.
-
Represents a system-level signal object. This\ type\ is\ thread\ safe.
-
Provides one spin lock that can give one thread exclusive access to one resource in multi-thread environments.
-
Similar to SpinLock, but allows the lock to be obtained mutable times from the same thread.
-
The RAII wrapper that locks the specified lock upon construction, and unlocks the specified lock upon destruction.
-
Represents a system thread object. This\ type\ is\ thread\ safe.
-
Represents a waitable object used for multi-thread synchronization.
Enumerations
-
Specifies the thread schedule priority.
Functions
-
Creates a new mutex object.
-
Ref< IReadWriteLock > new_read_write_lock()
Creates one new read write lock.
-
Ref< ISemaphore > new_semaphore(i32 initial_count, i32 max_count)
Create a new semaphore object.
-
Ref< ISignal > new_signal(bool manual_reset)
Create a new signal object.
-
Gets the number of logical processors on the platform.
-
Create a new system thread and make it run the callback function. The thread will be closed when the callback function returns.
-
IThread * get_current_thread()
Gets the thread object of current running thread.
-
Gets the thread object of the main thread.
-
void sleep(u32 time_milliseconds)
Suspends current thread for a specific period of time.
-
void fast_sleep(u32 time_microseconds)
Delays the execution of this thread for a very shout time by yielding this thread several times.
-
Yields the remain time slice of the current thread and let OS to schedule other threads.
-
opaque_t tls_alloc(void(destructor)(void ptr)=nullptr)
Allocates one thread local storage (TLS) slot.
-
void tls_free(opaque_t handle)
Frees the TLS slot allocated by
tls_alloc
. -
void tls_set(opaque_t handle, void *ptr)
Set the data bound to the current thread's TLS slot specified by
handle
. -
void * tls_get(opaque_t handle)
Get the value bound to the TLS slot of current thread.