Zth (libzth)
sync

Functions

int zth_mutex_init (zth_mutex_t *mutex) noexcept
 Initializes a mutex. More...
 
int zth_mutex_destroy (zth_mutex_t *mutex) noexcept
 Destroys a mutex. More...
 
int zth_mutex_lock (zth_mutex_t *mutex) noexcept
 Locks a mutex. More...
 
int zth_mutex_trylock (zth_mutex_t *mutex) noexcept
 Try to lock a mutex. More...
 
int zth_mutex_unlock (zth_mutex_t *mutex) noexcept
 Unlock a mutex. More...
 
int zth_sem_init (zth_sem_t *sem, size_t value) noexcept
 Initializes a semaphore. More...
 
int zth_sem_destroy (zth_sem_t *sem) noexcept
 Destroys a semaphore. More...
 
int zth_sem_getvalue (zth_sem_t *__restrict__ sem, size_t *__restrict__ value) noexcept
 Returns the value of a semaphore. More...
 
int zth_sem_post (zth_sem_t *sem) noexcept
 Increments a semaphore. More...
 
int zth_sem_wait (zth_sem_t *sem) noexcept
 Decrements (or wait for) a semaphore. More...
 
int zth_sem_trywait (zth_sem_t *sem) noexcept
 Try to decrement a semaphore. More...
 
int zth_cond_init (zth_cond_t *cond) noexcept
 Initializes a condition. More...
 
int zth_cond_destroy (zth_cond_t *cond) noexcept
 Destroys a condition. More...
 
int zth_cond_signal (zth_cond_t *cond) noexcept
 Signals one fiber waiting for the condition. More...
 
int zth_cond_broadcast (zth_cond_t *cond) noexcept
 Signals all fibers waiting for the condition. More...
 
int zth_cond_wait (zth_cond_t *cond) noexcept
 Wait for a condition. More...
 
int zth_future_init (zth_future_t *future) noexcept
 Initializes a future. More...
 
int zth_future_destroy (zth_future_t *future) noexcept
 Destroys a future. More...
 
int zth_future_valid (zth_future_t *future) noexcept
 Checks if a future was already set. More...
 
int zth_future_set (zth_future_t *future, uintptr_t value) noexcept
 Sets a future and signals all waiting fibers. More...
 
int zth_future_get (zth_future_t *__restrict__ future, uintptr_t *__restrict__ value) noexcept
 Wait for and return a future's value. More...
 
int zth_future_wait (zth_future_t *future) noexcept
 Wait for a future. More...
 
int zth_gate_init (zth_gate_t *gate, size_t count) noexcept
 Initializes a gate. More...
 
int zth_gate_destroy (zth_gate_t *gate) noexcept
 Destroys a gate. More...
 
int zth_gate_pass (zth_gate_t *gate) noexcept
 Passes a gate. More...
 
int zth_gate_wait (zth_gate_t *gate) noexcept
 Wait for a gate. More...
 

Detailed Description

Function Documentation

◆ zth_cond_broadcast()

int zth_cond_broadcast ( zth_cond_t cond)
noexcept

Signals all fibers waiting for the condition.

This is a C-wrapper for zth::Signal::signalAll().

Definition at line 1065 of file sync.h.

◆ zth_cond_destroy()

int zth_cond_destroy ( zth_cond_t cond)
noexcept

Destroys a condition.

This is a C-wrapper to delete a zth::Signal.

Definition at line 1033 of file sync.h.

◆ zth_cond_init()

int zth_cond_init ( zth_cond_t cond)
noexcept

Initializes a condition.

This is a C-wrapper to create a new zth::Signal.

Definition at line 1013 of file sync.h.

◆ zth_cond_signal()

int zth_cond_signal ( zth_cond_t cond)
noexcept

Signals one fiber waiting for the condition.

This is a C-wrapper for zth::Signal::signal().

Definition at line 1051 of file sync.h.

◆ zth_cond_wait()

int zth_cond_wait ( zth_cond_t cond)
noexcept

Wait for a condition.

This is a C-wrapper for zth::Signal::wait().

Definition at line 1079 of file sync.h.

◆ zth_future_destroy()

int zth_future_destroy ( zth_future_t future)
noexcept

Destroys a future.

This is a C-wrapper to delete a zth::Future.

Definition at line 1119 of file sync.h.

◆ zth_future_get()

int zth_future_get ( zth_future_t *__restrict__  future,
uintptr_t *__restrict__  value 
)
noexcept

Wait for and return a future's value.

This is a C-wrapper for zth::Future::value().

Definition at line 1169 of file sync.h.

◆ zth_future_init()

int zth_future_init ( zth_future_t future)
noexcept

Initializes a future.

This is a C-wrapper to create a new zth::Future.

Definition at line 1099 of file sync.h.

◆ zth_future_set()

int zth_future_set ( zth_future_t future,
uintptr_t  value 
)
noexcept

Sets a future and signals all waiting fibers.

This is a C-wrapper for zth::Future::set().

Definition at line 1150 of file sync.h.

◆ zth_future_valid()

int zth_future_valid ( zth_future_t future)
noexcept

Checks if a future was already set.

This is a C-wrapper for zth::Future::valid().

Definition at line 1137 of file sync.h.

◆ zth_future_wait()

int zth_future_wait ( zth_future_t future)
noexcept

Wait for a future.

This is a C-wrapper for zth::Future::wait().

Definition at line 1183 of file sync.h.

◆ zth_gate_destroy()

int zth_gate_destroy ( zth_gate_t gate)
noexcept

Destroys a gate.

This is a C-wrapper to delete a zth::Gate.

Definition at line 1225 of file sync.h.

◆ zth_gate_init()

int zth_gate_init ( zth_gate_t gate,
size_t  count 
)
noexcept

Initializes a gate.

If all participants call zth_gate_wait(), the gate behaves the same as a pthread_barrier_t would.

This is a C-wrapper to create a new zth::Gate.

Definition at line 1205 of file sync.h.

◆ zth_gate_pass()

int zth_gate_pass ( zth_gate_t gate)
noexcept

Passes a gate.

This is a C-wrapper for zth::Gate::pass().

Definition at line 1243 of file sync.h.

◆ zth_gate_wait()

int zth_gate_wait ( zth_gate_t gate)
noexcept

Wait for a gate.

This is a C-wrapper for zth::Gate::wait().

Definition at line 1256 of file sync.h.

◆ zth_mutex_destroy()

int zth_mutex_destroy ( zth_mutex_t mutex)
noexcept

Destroys a mutex.

This is a C-wrapper to delete a zth::Mutex.

Definition at line 839 of file sync.h.

◆ zth_mutex_init()

int zth_mutex_init ( zth_mutex_t mutex)
noexcept

Initializes a mutex.

This is a C-wrapper to create a new zth::Mutex.

Definition at line 819 of file sync.h.

◆ zth_mutex_lock()

int zth_mutex_lock ( zth_mutex_t mutex)
noexcept

Locks a mutex.

This is a C-wrapper for zth::Mutex::lock().

Definition at line 857 of file sync.h.

◆ zth_mutex_trylock()

int zth_mutex_trylock ( zth_mutex_t mutex)
noexcept

Try to lock a mutex.

This is a C-wrapper for zth::Mutex::trylock().

Definition at line 871 of file sync.h.

◆ zth_mutex_unlock()

int zth_mutex_unlock ( zth_mutex_t mutex)
noexcept

Unlock a mutex.

This is a C-wrapper for zth::Mutex::unlock().

Definition at line 884 of file sync.h.

◆ zth_sem_destroy()

int zth_sem_destroy ( zth_sem_t sem)
noexcept

Destroys a semaphore.

This is a C-wrapper to delete a zth::Semaphore.

Definition at line 922 of file sync.h.

◆ zth_sem_getvalue()

int zth_sem_getvalue ( zth_sem_t *__restrict__  sem,
size_t *__restrict__  value 
)
noexcept

Returns the value of a semaphore.

This is a C-wrapper for zth::Semaphore::value().

Definition at line 941 of file sync.h.

◆ zth_sem_init()

int zth_sem_init ( zth_sem_t sem,
size_t  value 
)
noexcept

Initializes a semaphore.

This is a C-wrapper to create a new zth::Semaphore.

Definition at line 902 of file sync.h.

◆ zth_sem_post()

int zth_sem_post ( zth_sem_t sem)
noexcept

Increments a semaphore.

This is a C-wrapper for zth::Mutex::release() of 1.

Definition at line 959 of file sync.h.

◆ zth_sem_trywait()

int zth_sem_trywait ( zth_sem_t sem)
noexcept

Try to decrement a semaphore.

This is a C-wrapper based on zth::Mutex::acquire().

Definition at line 991 of file sync.h.

◆ zth_sem_wait()

int zth_sem_wait ( zth_sem_t sem)
noexcept

Decrements (or wait for) a semaphore.

This is a C-wrapper for zth::Mutex::acquire() of 1.

Definition at line 977 of file sync.h.