Semaphore.xml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Semaphore" inherits="Reference" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. A synchronization semaphore.
  5. </brief_description>
  6. <description>
  7. A synchronization semaphore which can be used to synchronize multiple [Thread]s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see [Mutex].
  8. [b]Warning:[/b]
  9. To guarantee that the operating system is able to perform proper cleanup (no crashes, no deadlocks), these conditions must be met:
  10. - By the time a [Semaphore]'s reference count reaches zero and therefore it is destroyed, no threads must be waiting on it.
  11. - By the time a [Thread]'s reference count reaches zero and therefore it is destroyed, it must not be waiting on any semaphore.
  12. </description>
  13. <tutorials>
  14. <link>$DOCS_URL/tutorials/performance/threads/using_multiple_threads.html</link>
  15. </tutorials>
  16. <methods>
  17. <method name="post">
  18. <return type="int" enum="Error" />
  19. <description>
  20. Lowers the [Semaphore], allowing one more thread in.
  21. [b]Note:[/b] This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be [constant OK].
  22. </description>
  23. </method>
  24. <method name="try_wait">
  25. <return type="int" enum="Error" />
  26. <description>
  27. Like [method wait], but won't block, so if the value is zero, fails immediately and returns [constant ERR_BUSY]. If non-zero, it returns [constant OK] to report success.
  28. </description>
  29. </method>
  30. <method name="wait">
  31. <return type="int" enum="Error" />
  32. <description>
  33. Waits for the [Semaphore], if its value is zero, blocks until non-zero.
  34. [b]Note:[/b] This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be [constant OK].
  35. </description>
  36. </method>
  37. </methods>
  38. <constants>
  39. </constants>
  40. </class>