class_thread.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Methods
  13. -------
  14. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`String<class_String>` | :ref:`get_id<class_Thread_method_get_id>` **(** **)** const |
  16. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`is_active<class_Thread_method_is_active>` **(** **)** const |
  18. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :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 **)** |
  20. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Variant<class_Variant>` | :ref:`wait_to_finish<class_Thread_method_wait_to_finish>` **(** **)** |
  22. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. Enumerations
  24. ------------
  25. .. _enum_Thread_Priority:
  26. .. _class_Thread_constant_PRIORITY_LOW:
  27. .. _class_Thread_constant_PRIORITY_NORMAL:
  28. .. _class_Thread_constant_PRIORITY_HIGH:
  29. enum **Priority**:
  30. - **PRIORITY_LOW** = **0**
  31. - **PRIORITY_NORMAL** = **1**
  32. - **PRIORITY_HIGH** = **2**
  33. Description
  34. -----------
  35. 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.
  36. Method Descriptions
  37. -------------------
  38. .. _class_Thread_method_get_id:
  39. - :ref:`String<class_String>` **get_id** **(** **)** const
  40. Returns the current ``Thread``\ s id, uniquely identifying it among all threads.
  41. .. _class_Thread_method_is_active:
  42. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  43. 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>`.
  44. .. _class_Thread_method_start:
  45. - :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 **)**
  46. 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.
  47. Returns OK on success, or ERR_CANT_CREATE on failure.
  48. .. _class_Thread_method_wait_to_finish:
  49. - :ref:`Variant<class_Variant>` **wait_to_finish** **(** **)**
  50. Joins the ``Thread`` and waits for it to finish. Returns what the method called returned.