|
Size: 2183
Comment: Added explanatory content
|
Size: 2196
Comment: slightly changed wording
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 7: | Line 7: |
| Use this function to coordinate threads in a multi-threaded environment. This function will wait for the condition variable to be signaled for the number of milliseconds passed in. If the time length requested elapses prior to the condition being signaled, this function returns with a SDL_MUTEX_TIMEDOUT value, otherwise it returns '0' meaning that the condition has been signaled. Thus function also unlocks the passed in mutex prior to waiting on the condition signal, and locks the mutex upon the condition being signaled, or the timeout. | Use this function to coordinate threads in a multi-threaded environment. This function will wait for the condition variable to be signaled or for the number of milliseconds passed in to elapse. If the time length requested elapses prior to the condition being signaled, this function returns with a SDL_MUTEX_TIMEDOUT value, otherwise it returns '0' meaning that the condition has been signaled. Thus function also unlocks the passed in mutex prior to waiting on the condition signal, and locks the mutex upon the condition being signaled, or the timeout. |
DRAFT |
SDL_CondWaitTimeout
Use this function to coordinate threads in a multi-threaded environment. This function will wait for the condition variable to be signaled or for the number of milliseconds passed in to elapse. If the time length requested elapses prior to the condition being signaled, this function returns with a SDL_MUTEX_TIMEDOUT value, otherwise it returns '0' meaning that the condition has been signaled. Thus function also unlocks the passed in mutex prior to waiting on the condition signal, and locks the mutex upon the condition being signaled, or the timeout.
Contents
Syntax
int SDL_CondWaitTimeout(SDL_cond* cond,
SDL_mutex* mutex,
Uint32 ms)
Function Parameters
cond |
The condition pointer whose signal will be waited on. |
mutex |
Mutex pointer used by user code to gate thread access. |
ms |
The maximum time to wait in milliseconds. Set to SDL_MUTEX_MAXWAIT for infinite wait. |
Return Value
Returns 0 if the condition variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not signaled in the allotted time, or a negative error code on failure; call SDL_GetError() for more information.
Code Examples
You can add your code example here
Remarks
mutex must be locked prior to calling this function. This function unlocks mutex, and it remains unlocked while this function waits for the condition signal, or the timeout to occur. In this way other threads within your program are free to make use of the shared resources while this function is in the waiting state.
When either the condition is signaled, or the timeout occurs, this function will lock mutex, prior to returning.
On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible.
