.\" Automatically generated by Pandoc 2.2.1 .\" .TH "al_wait_cond" "3alleg5" "" "Allegro reference manual" "" .hy .SH NAME .PP al_wait_cond \- Allegro 5 API .SH SYNOPSIS .IP .nf \f[C] #include\ void\ al_wait_cond(ALLEGRO_COND\ *cond,\ ALLEGRO_MUTEX\ *mutex) \f[] .fi .SH DESCRIPTION .PP On entering this function, \f[C]mutex\f[] must be locked by the calling thread. The function will atomically release \f[C]mutex\f[] and block on \f[C]cond\f[]. The function will return when \f[C]cond\f[] is \[lq]signalled\[rq], acquiring the lock on the mutex in the process. .PP Example of proper use: .IP .nf \f[C] al_lock_mutex(mutex); while\ (something_not_true)\ { \ \ \ al_wait_cond(cond,\ mutex); } do_something(); al_unlock_mutex(mutex); \f[] .fi .PP The mutex should be locked before checking the condition, and should be rechecked al_wait_cond(3alleg5) returns. al_wait_cond(3alleg5) can return for other reasons than the condition becoming true (e.g.\ the process was signalled). If multiple threads are blocked on the condition variable, the condition may no longer be true by the time the second and later threads are unblocked. Remember not to unlock the mutex prematurely. .SH SEE ALSO .PP al_wait_cond_until(3alleg5), al_broadcast_cond(3alleg5), al_signal_cond(3alleg5).