NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
REL="HOME"
TITLE="SDL Library Documentation"
REL="UP"
TITLE="Multi-threaded Programming"
REL="PREVIOUS"
TITLE="SDL_DestroySemaphore"
HREF="sdldestroysemaphore.html"><
LINK
REL="NEXT"
TITLE="SDL_SemTryWait"
HREF="sdlsemtrywait.html"><
/HEAD
CLASS="REFENTRY"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
CLASS="NAVHEADER"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation<
/TH
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
HREF="sdldestroysemaphore.html"
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
HREF="sdlsemtrywait.html"
ALIGN="LEFT"
NAME="SDLSEMWAIT"
CLASS="REFNAMEDIV"
NAME="AEN7474"
>SDL_SemWait -- Lock a semaphore and suspend the thread if the semaphore
value is zero.<
/DIV
CLASS="REFSYNOPSISDIV"
NAME="AEN7477"
CLASS="FUNCSYNOPSIS"
NAME="AEN7478"
CLASS="FUNCSYNOPSISINFO"
>#include "SDL.h"
#include
"SDL_thread.h"<
/PRE
CLASS="FUNCDEF"
CLASS="FSFUNC"
CLASS="REFSECT1"
NAME="AEN7484"
CLASS="FUNCTION"
> suspends the calling thread until either
the semaphore pointed to by <
TT
CLASS="PARAMETER"
> has a positive value,
the call is interrupted by a signal or error. If the call is successful it
will atomically decrement the semaphore
value.<
/P
CLASS="FUNCTION"
> is successful, the semaphore
can be released and its count atomically incremented by a successful call to
HREF="sdlsempost.html"
CLASS="REFSECT1"
NAME="AEN7492"
CLASS="RETURNVALUE"
> if successful or
CLASS="RETURNVALUE"
> if there was an error
(leaving the semaphore unchanged
).<
/P
CLASS="REFSECT1"
NAME="AEN7497"
CLASS="PROGRAMLISTING"
>if (SDL_SemWait(my_sem) == -1) {
return WAIT_FAILED;
}
...
SDL_SemPost
(my_sem
);<
/PRE
CLASS="REFSECT1"
NAME="AEN7501"
HREF="sdlcreatesemaphore.html"
CLASS="FUNCTION"
>,
HREF="sdldestroysemaphore.html"
CLASS="FUNCTION"
>SDL_DestroySemaphore<
/TT
>,
HREF="sdlsemtrywait.html"
CLASS="FUNCTION"
>,
HREF="sdlsemwaittimeout.html"
CLASS="FUNCTION"
>,
HREF="sdlsempost.html"
CLASS="FUNCTION"
>,
HREF="sdlsemvalue.html"
CLASS="FUNCTION"
CLASS="NAVFOOTER"
ALIGN="LEFT"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
HREF="sdldestroysemaphore.html"
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="index.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
HREF="sdlsemtrywait.html"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_DestroySemaphore<
/TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="thread.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>