Sets up a mutex. It is recursive: the thread that holds it can lock it again, and has to unlock it as many times.
- desired_name: a label for the mutex. Only kept in builds with
DEBUGset. - desired_order: a rank for the mutex. Only kept in builds with
DEBUGset; nothing acts on it yet. -1 for none.
init :: (m: *Mutex, desired_name := "", desired_order: Mutex_Order = -1)
Sets up a mutex. It is recursive: the thread that holds it can lock it again, and has to unlock it as many times.
Parameters
- m: *Mutex
- desired_name := ""
- a label for the mutex. Only kept in builds with
DEBUGset. - desired_order: Mutex_Order = -1
- a rank for the mutex. Only kept in builds with
DEBUGset; nothing acts on it yet. -1 for none.
init :: (cv: *Condition_Variable, desired_name := "")
Sets up a condition variable.
Parameters
- cv: *Condition_Variable
- desired_name := ""
- a label for the condition variable. Only kept in builds with
DEBUGset.
init :: (s: *Semaphore, initial_value: s32 = 0)
Sets up a semaphore.
Parameters
- s: *Semaphore
- initial_value: s32 = 0
- how many
wait_forcalls succeed before anyone callssignal.
init :: (m: *Mutex, desired_name := "", desired_order: Mutex_Order = -1)
Sets up a mutex. It is recursive: the thread that holds it can lock it again, and has to unlock it as many times.
Parameters
- m: *Mutex
- desired_name := ""
- a label for the mutex. Only kept in builds with
DEBUGset. - desired_order: Mutex_Order = -1
- a rank for the mutex. Only kept in builds with
DEBUGset; nothing acts on it yet. -1 for none.
mutex: Mutex;
init(*mutex);
defer destroy(*mutex);
lock(*mutex);
lock(*mutex); // the same thread may lock again
unlock(*mutex);
unlock(*mutex);init :: (cv: *Condition_Variable, desired_name := "")
Sets up a condition variable.
Parameters
- cv: *Condition_Variable
- desired_name := ""
- a label for the condition variable. Only kept in builds with
DEBUGset.
ready: Condition_Variable;
init(*ready);
defer destroy(*ready);init :: (s: *Semaphore, initial_value: s32 = 0)
Sets up a semaphore.
Parameters
- s: *Semaphore
- initial_value: s32 = 0
- how many
wait_forcalls succeed before anyone callssignal.
semaphore: Semaphore;
init(*semaphore, 1);
defer destroy(*semaphore);
assert(wait_for(*semaphore, 0) == .SUCCESS);
assert(wait_for(*semaphore, 0) == .TIMEOUT);init :: (
group: *Thread_Group,
num_threads: s32,
group_proc: Thread_Group_Proc,
enable_work_stealing := false,
temporary_storage_size: s32 = 16384,
group_name := ""
)
Sets up group with num_threads worker threads that call group_proc for each piece of work. The workers are created
but do not run until start.
Parameters
- group: *Thread_Group
- num_threads: s32
- group_proc: Thread_Group_Proc
- enable_work_stealing := false
- lets an idle worker take work queued for another.
- temporary_storage_size: s32 = 16384
- bytes of temporary storage for each worker.
- group_name := ""
- used in log messages.