class_thread.rst 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Thread.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Thread:
  5. Thread
  6. ======
  7. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A unit of execution in a process.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`String<class_string>` | :ref:`get_id<class_Thread_get_id>` **(** **)** const |
  16. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`is_active<class_Thread_is_active>` **(** **)** const |
  18. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`start<class_Thread_start>` **(** :ref:`Object<class_object>` instance, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` userdata=null, :ref:`int<class_int>` priority=1 **)** |
  20. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Variant<class_variant>` | :ref:`wait_to_finish<class_Thread_wait_to_finish>` **(** **)** |
  22. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. Enums
  24. -----
  25. .. _enum_Thread_Priority:
  26. enum **Priority**
  27. - **PRIORITY_LOW** = **0**
  28. - **PRIORITY_NORMAL** = **1**
  29. - **PRIORITY_HIGH** = **2**
  30. Description
  31. -----------
  32. A unit of execution in a process. Can run methods on :ref:`Object<class_object>`\ s simultaneously. The use of synchronization via :ref:`Mutex<class_mutex>`, :ref:`Semaphore<class_semaphore>` is advised if working with shared objects.
  33. Member Function Description
  34. ---------------------------
  35. .. _class_Thread_get_id:
  36. - :ref:`String<class_string>` **get_id** **(** **)** const
  37. Returns the current ``Thread``\ s id, uniquely identifying it among all threads.
  38. .. _class_Thread_is_active:
  39. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  40. Returns true if this ``Thread`` is currently active. An active ``Thread`` cannot start work on a new method but can be joined with :ref:`wait_to_finish<class_Thread_wait_to_finish>`.
  41. .. _class_Thread_start:
  42. - :ref:`int<class_int>` **start** **(** :ref:`Object<class_object>` instance, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` userdata=null, :ref:`int<class_int>` priority=1 **)**
  43. Starts a new ``Thread`` that runs "method" on object "instance" with "userdata" passed as an argument. The "priority" of the ``Thread`` can be changed by passing a PRIORITY\_\* enum.
  44. Returns OK on success, or ERR_CANT_CREATE on failure.
  45. .. _class_Thread_wait_to_finish:
  46. - :ref:`Variant<class_variant>` **wait_to_finish** **(** **)**
  47. Joins the ``Thread`` and waits for it to finish. Returns what the method called returned.