comparison src/thread/generic/SDL_syscond.c @ 5112:0846f18eb625

Improved condition variable documentation
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Jan 2011 10:40:17 -0800
parents f7b03b6838cb
children b530ef003506
comparison
equal deleted inserted replaced
5111:5df0c142db9b 5112:0846f18eb625
143 The mutex is unlocked during the wait, and locked again after the wait. 143 The mutex is unlocked during the wait, and locked again after the wait.
144 144
145 Typical use: 145 Typical use:
146 146
147 Thread A: 147 Thread A:
148 SDL_LockMutex(lock); 148 SDL_LockMutex(lock);
149 while ( ! condition ) { 149 while ( ! condition ) {
150 SDL_CondWait(cond); 150 SDL_CondWait(cond, lock);
151 } 151 }
152 SDL_UnlockMutex(lock); 152 SDL_UnlockMutex(lock);
153 153
154 Thread B: 154 Thread B:
155 SDL_LockMutex(lock); 155 SDL_LockMutex(lock);
156 ... 156 ...
157 condition = true; 157 condition = true;
158 ... 158 ...
159 SDL_UnlockMutex(lock); 159 SDL_CondSignal(cond);
160 SDL_UnlockMutex(lock);
160 */ 161 */
161 int 162 int
162 SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) 163 SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
163 { 164 {
164 int retval; 165 int retval;