Wiki Page Content

Revision 3 as of 2010-09-09 20:57:09

Clear message

DRAFT

SDL_SemWait

Use this function to suspend the calling thread until the semaphore pointed to by sem has a positive count, then atomically decrease the semaphore count -or- ...suspend the calling thread until the semaphore can be atomically decremented -or- *lock a semaphore and suspend the thread if the semaphore value is zero*.

Syntax

int SDL_SemWait(SDL_sem* sem)

Function Parameters

sem

a pointer to the SDL_sem structure / semaphore to be monitored

Return Value

Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

If the semaphore was not successfully locked, the semaphore will be unchanged. ???

Code Examples

*

if (SDL_SemWait(my_sem) == -1) {
        return WAIT_FAILED;
}

...

SDL_SemPost(my_sem);

*

Remarks

*
SDL_SemWait() suspends the calling thread until either the semaphore pointed to by sem has a positive value or the call is interrupted by a signal or error. If the call is successful it will atomically decrement the semaphore value.

After SDL_SemWait() is successful, the semaphore can be released and its count atomically incremented by a successful call to SDL_SemPost().
*

green


CategoryAPI, CategoryMutex

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit