home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_SemWaitTimeout.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  2.5 KB  |  73 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_SemWaitTimeout"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_SemWaitTimeout- Lock a semaphore, but only wait up to a specified
  13. maximum time. 
  14. <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
  15. <p>
  16. <b>#include "SDL.h" #include "SDL_thread.h" <p>
  17. </b><b>int <b>SDL_SemWaitTimeout</b></b>(<b>SDL_sem
  18. *sem, Uint32 timeout</b>); 
  19. <h2><a name='sect2' href='#toc2'>Description</a></h2>
  20. <p>
  21. <b>SDL_SemWaitTimeout()</b> is a varient of
  22. <i>SDL_SemWait</i> with a maximum timeout value. If the value of the semaphore
  23. pointed to by <b>sem</b> is positive (greater than zero) it will atomically decrement
  24. the semaphore value and return 0, otherwise it will wait up to <b>timeout</b>
  25. milliseconds trying to lock the semaphore. This function is to be avoided
  26. if possible since on some platforms it is implemented by polling the semaphore
  27. every millisecond in a busy loop. <p>
  28. After <b>SDL_SemWaitTimeout()</b> is successful,
  29. the semaphore can be released and its count atomically incremented by a
  30. successful call to <i>SDL_SemPost</i>. 
  31. <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
  32. <p>
  33. Returns <b>0</b> if the semaphore was
  34. successfully locked or either <b>SDL_MUTEX_TIMEOUT</b> or <b>-1</b> if the timeout period
  35. was exceeded or there was an error, respectivly. <p>
  36. If the semaphore was not
  37. successfully locked, the semaphore will be unchanged. 
  38. <h2><a name='sect4' href='#toc4'>Examples</a></h2>
  39. <p>
  40. <p>
  41. <br>
  42. <pre>CWres = SDL_SemWaitTimeout(my_sem, WAIT_TIMEOUT_MILLISEC);
  43. if (res == SDL_MUTEX_TIMEOUT) {
  44.         return TRY_AGAIN;
  45. }
  46. if (res == -1) {
  47.         return WAIT_ERROR;
  48. }
  49. ...
  50. SDL_SemPost(my_sem);
  51. </pre><p>
  52.  
  53. <h2><a name='sect5' href='#toc5'>See Also</a></h2>
  54. <p>
  55. <i><b>SDL_CreateSemaphore</b></i>, <i><b>SDL_DestroySemaphore</b></i>, <i><b>SDL_SemWait</b></i>, <i><b>SDL_SemTryWait</b></i>,
  56. <i><b>SDL_SemPost</b></i>, <i><b>SDL_SemValue</b></i> 
  57. <!--
  58.   
  59.  <p>
  60.  
  61. <hr><p>
  62. <a name='toc'><b>Table of Contents</b></a><p>
  63. <ul>
  64. <li><a name='toc0' href='#sect0'>Name</a></li>
  65. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  66. <li><a name='toc2' href='#sect2'>Description</a></li>
  67. <li><a name='toc3' href='#sect3'>Return Value</a></li>
  68. <li><a name='toc4' href='#sect4'>Examples</a></li>
  69. <li><a name='toc5' href='#sect5'>See Also</a></li>
  70. </ul>
  71. </body>
  72. </html>
  73.