class_thread.rst 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Thread.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Thread:
  6. Thread
  7. ======
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A unit of execution in a process.
  13. Methods
  14. -------
  15. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`String<class_String>` | :ref:`get_id<class_Thread_method_get_id>` **(** **)** const |
  17. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`is_active<class_Thread_method_is_active>` **(** **)** const |
  19. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`start<class_Thread_method_start>` **(** :ref:`Object<class_Object>` instance, :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` userdata=null, :ref:`int<class_int>` priority=1 **)** |
  21. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Variant<class_Variant>` | :ref:`wait_to_finish<class_Thread_method_wait_to_finish>` **(** **)** |
  23. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. Enumerations
  25. ------------
  26. .. _enum_Thread_Priority:
  27. .. _class_Thread_constant_PRIORITY_LOW:
  28. .. _class_Thread_constant_PRIORITY_NORMAL:
  29. .. _class_Thread_constant_PRIORITY_HIGH:
  30. enum **Priority**:
  31. - **PRIORITY_LOW** = **0**
  32. - **PRIORITY_NORMAL** = **1**
  33. - **PRIORITY_HIGH** = **2**
  34. Description
  35. -----------
  36. 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.
  37. Method Descriptions
  38. -------------------
  39. .. _class_Thread_method_get_id:
  40. - :ref:`String<class_String>` **get_id** **(** **)** const
  41. Returns the current ``Thread``\ s id, uniquely identifying it among all threads.
  42. ----
  43. .. _class_Thread_method_is_active:
  44. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  45. 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_method_wait_to_finish>`.
  46. ----
  47. .. _class_Thread_method_start:
  48. - :ref:`Error<enum_@GlobalScope_Error>` **start** **(** :ref:`Object<class_Object>` instance, :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` userdata=null, :ref:`int<class_int>` priority=1 **)**
  49. 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.
  50. Returns OK on success, or ERR_CANT_CREATE on failure.
  51. ----
  52. .. _class_Thread_method_wait_to_finish:
  53. - :ref:`Variant<class_Variant>` **wait_to_finish** **(** **)**
  54. Joins the ``Thread`` and waits for it to finish. Returns what the method called returned.