Zth (libzth)
Loading...
Searching...
No Matches
sync

Functions

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

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 1191 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 1159 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 1139 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 1177 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 1205 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 1245 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 1295 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 1225 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 1276 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 1263 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 1309 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 1351 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 1331 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 1369 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 1382 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 965 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 945 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 983 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 997 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 1010 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 1048 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 1067 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 1028 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 1085 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 1117 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 1103 of file sync.h.