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.
 
int zth_mailbox_init (zth_mailbox_t *mailbox) noexcept
 Initializes a mailbox.
 
int zth_mailbox_destroy (zth_mailbox_t *mailbox) noexcept
 Destroys a mailbox.
 
int zth_mailbox_can_take (zth_mailbox_t *mailbox) noexcept
 Checks if a mailbox contains data to take.
 
int zth_mailbox_can_put (zth_mailbox_t *mailbox) noexcept
 Checks if a mailbox is empty and can accept data.
 
int zth_mailbox_put (zth_mailbox_t *mailbox, uintptr_t value) noexcept
 Puts a value into the mailbox.
 
int zth_mailbox_take (zth_mailbox_t *__restrict__ mailbox, uintptr_t *__restrict__ value) noexcept
 Wait for and return a mailbox's value.
 

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 1799 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 1767 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 1747 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 1785 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 1813 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 1853 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 1903 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 1833 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 1884 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 1871 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 1917 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 1959 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 1939 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 1977 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 1990 of file sync.h.

◆ zth_mailbox_can_put()

int zth_mailbox_can_put ( zth_mailbox_t mailbox)
noexcept

Checks if a mailbox is empty and can accept data.

This is a C-wrapper for zth::Mailbox::can_put().

Definition at line 2061 of file sync.h.

◆ zth_mailbox_can_take()

int zth_mailbox_can_take ( zth_mailbox_t mailbox)
noexcept

Checks if a mailbox contains data to take.

This is a C-wrapper for zth::Mailbox::can_take().

Definition at line 2048 of file sync.h.

◆ zth_mailbox_destroy()

int zth_mailbox_destroy ( zth_mailbox_t mailbox)
noexcept

Destroys a mailbox.

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

Definition at line 2030 of file sync.h.

◆ zth_mailbox_init()

int zth_mailbox_init ( zth_mailbox_t mailbox)
noexcept

Initializes a mailbox.

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

Definition at line 2010 of file sync.h.

◆ zth_mailbox_put()

int zth_mailbox_put ( zth_mailbox_t mailbox,
uintptr_t  value 
)
noexcept

Puts a value into the mailbox.

This is a C-wrapper for zth::Mailbox::put(). It is blocking when there is already a value in the mailbox.

Definition at line 2075 of file sync.h.

◆ zth_mailbox_take()

int zth_mailbox_take ( zth_mailbox_t *__restrict__  mailbox,
uintptr_t *__restrict__  value 
)
noexcept

Wait for and return a mailbox's value.

This is a C-wrapper for zth::Mailbox::take().

Definition at line 2091 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 1570 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 1550 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 1588 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 1602 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 1615 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 1656 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 1675 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 1633 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 1693 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 1725 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 1711 of file sync.h.