#import "std/sync"
Multiplatform implementation of various thread synchronization tools.
TODO: Improve documentation.
Mutex :: _sync_impl.Mutex
Mutex type.
File: sync.bl
Condition :: _sync_impl.Condition
File: sync.bl
Semaphore :: struct {
mutex: Mutex;
cond: Condition;
value: u32;
}
File: sync.bl
mutex_init :: fn (mutex: *Mutex) Error #inline
Initialize mutex. Call mutex_terminate when mutex is no longer needed.
File: sync.bl
mutex_terminate :: fn (mutex: *Mutex) Error #inline
Terminate mutex.
File: sync.bl
mutex_lock :: fn (mutex: *Mutex) Error #inline
Lock mutex and enter critical section.
File: sync.bl
mutex_try_lock :: fn (mutex: *Mutex) (_0: bool, _1: Error) #inline
Try to lock the mutex
. Returns true
in case the mutex was locked or false
if mutex
is already locked or en error occurred.
File: sync.bl
mutex_unlock :: fn (mutex: *Mutex) Error #inline
Unlock previously locked mutex and leave critical section.
File: sync.bl
semaphore_init :: fn (sem: *Semaphore, v : u32: 0) Error #inline
Initialize semaphore
object with value
.
File: sync.bl
semaphore_terminate :: fn (sem: *Semaphore) Error #inline
Terminate semaphore
object.
File: sync.bl
semaphore_wait :: fn (sem: *Semaphore) Error #inline
File: sync.bl
semaphore_post :: fn (sem: *Semaphore) Error #inline
File: sync.bl
condition_init :: fn (condition: *Condition) Error #inline
File: sync.bl
condition_terminate :: fn (_: *Condition) Error #inline
File: sync.bl
condition_wait :: fn (condition: *Condition, mutex: *Mutex) Error #inline
File: sync.bl
condition_signal :: fn (condition: *Condition) Error #inline
File: sync.bl