Wiki Page Content

Differences between revisions 3 and 4
Revision 3 as of 2010-09-09 20:57:09
Size: 2022
Editor: SheenaSmith
Comment: update content (old wiki)
Revision 4 as of 2010-10-12 06:05:03
Size: 1987
Editor: SheenaSmith
Comment: update content - pointers, structs
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
||'''sem'''||^a pointer to the SDL_sem structure / semaphore to be monitored^|| ||'''sem'''||^the SDL_sem to be monitored^||

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

the SDL_sem 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

None: SDL_SemWait (last edited 2013-10-05 19:37:34 by PhilippWiesemann)

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