mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-06 22:09:55 +03:00
Currently including `zh_CN` and `es` which both have very high completion ratios. Others will be added once they reach a significant percentage too. These RST files will be used by godot-docs in place of its `classes` folder after we sync with https://github.com/godotengine/godot-docs/pull/5458. The update workflow is manual for now (example for `zh_CN`): - Build `godotengine/godot` in the branch we currently track (now `3.x`) - Run `godot --doctool -l zh_CN` - Run `cd doc && make rst LANGARG=zh_CN` - Copy `doc/_build/rst/*` to `classes/zh_CN/` here - Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
120 lines
7.2 KiB
ReStructuredText
120 lines
7.2 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Thread.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Thread:
|
|
|
|
Thread
|
|
======
|
|
|
|
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
Una unidad de ejecución en un proceso.
|
|
|
|
Descripción
|
|
----------------------
|
|
|
|
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>` or :ref:`Semaphore<class_Semaphore>` is advised if working with shared objects.
|
|
|
|
\ **Note:** Breakpoints won't break on code if it's running in a thread. This is a current limitation of the GDScript debugger.
|
|
|
|
Tutoriales
|
|
--------------------
|
|
|
|
- :doc:`Using multiple threads <../tutorials/performance/threads/using_multiple_threads>`
|
|
|
|
- :doc:`Thread-safe APIs <../tutorials/performance/threads/thread_safe_apis>`
|
|
|
|
- `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
|
|
|
|
Métodos
|
|
--------------
|
|
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_id<class_Thread_method_get_id>` **(** **)** |const| |
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_active<class_Thread_method_is_active>` **(** **)** |const| |
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_alive<class_Thread_method_is_alive>` **(** **)** |const| |
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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:`Priority<enum_Thread_Priority>` priority=1 **)** |
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Variant<class_Variant>` | :ref:`wait_to_finish<class_Thread_method_wait_to_finish>` **(** **)** |
|
|
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Enumeraciones
|
|
--------------------------
|
|
|
|
.. _enum_Thread_Priority:
|
|
|
|
.. _class_Thread_constant_PRIORITY_LOW:
|
|
|
|
.. _class_Thread_constant_PRIORITY_NORMAL:
|
|
|
|
.. _class_Thread_constant_PRIORITY_HIGH:
|
|
|
|
enum **Priority**:
|
|
|
|
- **PRIORITY_LOW** = **0** --- Un hilo que corre con menor prioridad de lo normal.
|
|
|
|
- **PRIORITY_NORMAL** = **1** --- Un hilo con una prioridad estándar.
|
|
|
|
- **PRIORITY_HIGH** = **2** --- Un hilo que corre con mayor prioridad de lo normal.
|
|
|
|
Descripciones de Métodos
|
|
------------------------------------------------
|
|
|
|
.. _class_Thread_method_get_id:
|
|
|
|
- :ref:`String<class_String>` **get_id** **(** **)** |const|
|
|
|
|
Returns the current ``Thread``'s ID, uniquely identifying it among all threads. If the ``Thread`` is not running this returns an empty string.
|
|
|
|
----
|
|
|
|
.. _class_Thread_method_is_active:
|
|
|
|
- :ref:`bool<class_bool>` **is_active** **(** **)** |const|
|
|
|
|
Returns ``true`` if this ``Thread`` has been started. Once started, this will return ``true`` until it is joined using :ref:`wait_to_finish<class_Thread_method_wait_to_finish>`. For checking if a ``Thread`` is still executing its task, use :ref:`is_alive<class_Thread_method_is_alive>`.
|
|
|
|
----
|
|
|
|
.. _class_Thread_method_is_alive:
|
|
|
|
- :ref:`bool<class_bool>` **is_alive** **(** **)** |const|
|
|
|
|
Returns ``true`` if this ``Thread`` is currently running. This is useful for determining if :ref:`wait_to_finish<class_Thread_method_wait_to_finish>` can be called without blocking the calling thread.
|
|
|
|
To check if a ``Thread`` is joinable, use :ref:`is_active<class_Thread_method_is_active>`.
|
|
|
|
----
|
|
|
|
.. _class_Thread_method_start:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **start** **(** :ref:`Object<class_Object>` instance, :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` userdata=null, :ref:`Priority<enum_Thread_Priority>` priority=1 **)**
|
|
|
|
Inicia un nuevo ``Thread`` que ejecuta ``method`` en el objeto ``instance`` con ``userdata`` pasado como argumento. Aunque no se pasen userdata, ``method`` debe aceptar un argumento y será nulo. La ``priority`` del ``Thread`` puede cambiarse pasando un valor del enum :ref:`Priority<enum_Thread_Priority>`.
|
|
|
|
Devuelve :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` en el éxito, o :ref:`@GlobalScope.ERR_CANT_CREATE<class_@GlobalScope_constant_ERR_CANT_CREATE>` en el fracaso.
|
|
|
|
----
|
|
|
|
.. _class_Thread_method_wait_to_finish:
|
|
|
|
- :ref:`Variant<class_Variant>` **wait_to_finish** **(** **)**
|
|
|
|
Joins the ``Thread`` and waits for it to finish. Returns the output of the method passed to :ref:`start<class_Thread_method_start>`.
|
|
|
|
Should either be used when you want to retrieve the value returned from the method called by the ``Thread`` or before freeing the instance that contains the ``Thread``.
|
|
|
|
To determine if this can be called without blocking the calling thread, check if :ref:`is_alive<class_Thread_method_is_alive>` is ``false``.
|
|
|
|
\ **Note:** After the ``Thread`` finishes joining it will be disposed. If you want to use it again you will have to create a new instance of it.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|