class_thread.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Thread:
  4. Thread
  5. ======
  6. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. A unit of execution in a process.
  11. Member Functions
  12. ----------------
  13. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`String<class_string>` | :ref:`get_id<class_Thread_get_id>` **(** **)** const |
  15. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`is_active<class_Thread_is_active>` **(** **)** const |
  17. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | Error | :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 **)** |
  19. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Variant<class_variant>` | :ref:`wait_to_finish<class_Thread_wait_to_finish>` **(** **)** |
  21. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. Numeric Constants
  23. -----------------
  24. - **PRIORITY_LOW** = **0**
  25. - **PRIORITY_NORMAL** = **1**
  26. - **PRIORITY_HIGH** = **2**
  27. Description
  28. -----------
  29. 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.
  30. Member Function Description
  31. ---------------------------
  32. .. _class_Thread_get_id:
  33. - :ref:`String<class_string>` **get_id** **(** **)** const
  34. Return the id of the thread, uniquely identifying it among all threads.
  35. .. _class_Thread_is_active:
  36. - :ref:`bool<class_bool>` **is_active** **(** **)** const
  37. Whether 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>`.
  38. .. _class_Thread_start:
  39. - Error **start** **(** :ref:`Object<class_object>` instance, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` userdata=NULL, :ref:`int<class_int>` priority=1 **)**
  40. Start a new :ref:`Thread<class_thread>`, it will run "method" on object "instance" using "userdata" as an argument and running with "priority", one of PRIORITY\_\* enum.
  41. Returns OK on success, or ERR_CANT_CREATE on failure.
  42. .. _class_Thread_wait_to_finish:
  43. - :ref:`Variant<class_variant>` **wait_to_finish** **(** **)**
  44. Joins the :ref:`Thread<class_thread>` and waits for it to finish. Returns what the method called returned.