home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_SemTryWait.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  2.3 KB  |  70 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_SemTryWait"("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_SemTryWait- Attempt to lock a semaphore but don't suspend the thread.
  13.  
  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_SemTryWait</b></b>(<b>SDL_sem
  18. *sem</b>); 
  19. <h2><a name='sect2' href='#toc2'>Description</a></h2>
  20. <p>
  21. <b>SDL_SemTryWait</b> is a non-blocking varient of <i><b>SDL_SemWait</b></i>.
  22. If the value of the semaphore pointed to by <b>sem</b> is positive it will atomically
  23. decrement the semaphore value and return 0, otherwise it will return <b>SDL_MUTEX_TIMEOUT</b>
  24. instead of suspending the thread. <p>
  25. After <b>SDL_SemTryWait</b> is successful, the
  26. semaphore can be released and its count atomically incremented by a successful
  27. call to <i>SDL_SemPost</i>. 
  28. <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
  29. <p>
  30. Returns <b>0</b> if the semaphore was successfully
  31. locked or either <b>SDL_MUTEX_TIMEOUT</b> or <b>-1</b> if the thread would have suspended
  32. or there was an error, respectivly. <p>
  33. If the semaphore was not successfully
  34. locked, the semaphore will be unchanged. 
  35. <h2><a name='sect4' href='#toc4'>Examples</a></h2>
  36. <p>
  37. <p>
  38. <br>
  39. <pre>CWres = SDL_SemTryWait(my_sem);
  40. if (res == SDL_MUTEX_TIMEOUT) {
  41.         return TRY_AGAIN;
  42. }
  43. if (res == -1) {
  44.         return WAIT_ERROR;
  45. }
  46. ...
  47. SDL_SemPost(my_sem);
  48. </pre><p>
  49.  
  50. <h2><a name='sect5' href='#toc5'>See Also</a></h2>
  51. <p>
  52. <i><b>SDL_CreateSemaphore</b></i>, <i><b>SDL_DestroySemaphore</b></i>, <i><b>SDL_SemWait</b></i>, <i><b>SDL_SemWaitTimeout</b></i>,
  53. <i><b>SDL_SemPost</b></i>, <i><b>SDL_SemValue</b></i> 
  54. <!--
  55.   
  56.  <p>
  57.  
  58. <hr><p>
  59. <a name='toc'><b>Table of Contents</b></a><p>
  60. <ul>
  61. <li><a name='toc0' href='#sect0'>Name</a></li>
  62. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  63. <li><a name='toc2' href='#sect2'>Description</a></li>
  64. <li><a name='toc3' href='#sect3'>Return Value</a></li>
  65. <li><a name='toc4' href='#sect4'>Examples</a></li>
  66. <li><a name='toc5' href='#sect5'>See Also</a></li>
  67. </ul>
  68. </body>
  69. </html>
  70.