home *** CD-ROM | disk | FTP | other *** search
- <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
- <!-- available at http://polyglotman.sourceforge.net/ -->
-
- <html>
- <head>
- <title>"SDL_SemWaitTimeout"("3") manual page</title>
- </head>
- <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
- <a href='#toc'>Table of Contents</a><p>
-
- <h2><a name='sect0' href='#toc0'>Name</a></h2>
- SDL_SemWaitTimeout- Lock a semaphore, but only wait up to a specified
- maximum time.
- <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
- <p>
- <b>#include "SDL.h" #include "SDL_thread.h" <p>
- </b><b>int <b>SDL_SemWaitTimeout</b></b>(<b>SDL_sem
- *sem, Uint32 timeout</b>);
- <h2><a name='sect2' href='#toc2'>Description</a></h2>
- <p>
- <b>SDL_SemWaitTimeout()</b> is a varient of
- <i>SDL_SemWait</i> with a maximum timeout value. If the value of the semaphore
- pointed to by <b>sem</b> is positive (greater than zero) it will atomically decrement
- the semaphore value and return 0, otherwise it will wait up to <b>timeout</b>
- milliseconds trying to lock the semaphore. This function is to be avoided
- if possible since on some platforms it is implemented by polling the semaphore
- every millisecond in a busy loop. <p>
- After <b>SDL_SemWaitTimeout()</b> is successful,
- the semaphore can be released and its count atomically incremented by a
- successful call to <i>SDL_SemPost</i>.
- <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
- <p>
- Returns <b>0</b> if the semaphore was
- successfully locked or either <b>SDL_MUTEX_TIMEOUT</b> or <b>-1</b> if the timeout period
- was exceeded or there was an error, respectivly. <p>
- If the semaphore was not
- successfully locked, the semaphore will be unchanged.
- <h2><a name='sect4' href='#toc4'>Examples</a></h2>
- <p>
- <p>
- <br>
- <pre>CWres = SDL_SemWaitTimeout(my_sem, WAIT_TIMEOUT_MILLISEC);
- if (res == SDL_MUTEX_TIMEOUT) {
- return TRY_AGAIN;
- }
- if (res == -1) {
- return WAIT_ERROR;
- }
- ...
- SDL_SemPost(my_sem);
- </pre><p>
-
- <h2><a name='sect5' href='#toc5'>See Also</a></h2>
- <p>
- <i><b>SDL_CreateSemaphore</b></i>, <i><b>SDL_DestroySemaphore</b></i>, <i><b>SDL_SemWait</b></i>, <i><b>SDL_SemTryWait</b></i>,
- <i><b>SDL_SemPost</b></i>, <i><b>SDL_SemValue</b></i>
- <!--
-
- <p>
-
- <hr><p>
- <a name='toc'><b>Table of Contents</b></a><p>
- <ul>
- <li><a name='toc0' href='#sect0'>Name</a></li>
- <li><a name='toc1' href='#sect1'>Synopsis</a></li>
- <li><a name='toc2' href='#sect2'>Description</a></li>
- <li><a name='toc3' href='#sect3'>Return Value</a></li>
- <li><a name='toc4' href='#sect4'>Examples</a></li>
- <li><a name='toc5' href='#sect5'>See Also</a></li>
- </ul>
- </body>
- </html>
-