File: al_wait_cond.3

package info (click to toggle)
allegro5 2%3A5.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,856 kB
  • ctags: 15,948
  • sloc: ansic: 87,540; cpp: 9,693; objc: 3,491; python: 2,057; sh: 829; makefile: 93; perl: 37; pascal: 24
file content (47 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.TH al_wait_cond 3 "" "Allegro reference manual"
.SH NAME
.PP
al_wait_cond \- Allegro 5 API
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <allegro5/allegro.h>

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 "signalled", 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(3) returns.
al_wait_cond(3) 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(3), al_broadcast_cond(3), al_signal_cond(3).