1SDL_SemWait(3) SDL API Reference SDL_SemWait(3)
2
3
4
6 SDL_SemWait - Lock a semaphore and suspend the thread if the semaphore
7 value is zero.
8
10 #include "SDL.h" #include "SDL_thread.h"
11
12 int SDL_SemWait(SDL_sem *sem);
13
15 SDL_SemWait() suspends the calling thread until either the semaphore
16 pointed to by sem has a positive value, the call is interrupted by a
17 signal or error. If the call is successful it will atomically decrement
18 the semaphore value.
19
20 After SDL_SemWait() is successful, the semaphore can be released and
21 its count atomically incremented by a successful call to SDL_SemPost.
22
24 Returns 0 if successful or -1 if there was an error (leaving the sema‐
25 phore unchanged).
26
28 if (SDL_SemWait(my_sem) == -1) {
29 return WAIT_FAILED;
30 }
31
32 ...
33
34 SDL_SemPost(my_sem);
35
37 SDL_CreateSemaphore, SDL_DestroySemaphore, SDL_SemTryWait, SDL_SemWait‐
38 Timeout, SDL_SemPost, SDL_SemValue
39
40
41
42SDL Tue 11 Sep 2001, 23:00 SDL_SemWait(3)