Difference between revisions of "Thread"
(Create love.thread.Thread page) |
m |
||
(12 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
− | A Thread | + | {{newin|[[0.7.0]]|070|type=type}} |
+ | A Thread is a chunk of code that can run in parallel with other threads. Data can be sent between different threads with [[Channel]] objects. | ||
+ | |||
== Constructors == | == Constructors == | ||
− | {{#ask: [[Category:Functions]] [[Constructs::Thread]] | + | {{#ask: [[Category:Functions]] [[Constructs::Thread]] [[Concept:Current]] |
| headers=hide | | headers=hide | ||
| default=None. | | default=None. | ||
+ | | format=template | ||
+ | | template=ListingFields | ||
+ | | introtemplate=ListingIntro | ||
+ | | outrotemplate=ListingOutro | ||
| ?Description | | ?Description | ||
+ | | ?PrettySince | ||
+ | | ?PrettyRemoved | ||
}} | }} | ||
== Functions == | == Functions == | ||
− | {{#ask: [[Category:Functions]] [[parent::Thread]] | + | {{#ask: [[Category:Functions]] [[parent::Thread||Object]] [[Concept:Current]] |
| headers=hide | | headers=hide | ||
+ | | format=template | ||
+ | | template=ListingFields | ||
+ | | introtemplate=ListingIntro | ||
+ | | outrotemplate=ListingOutro | ||
| ?Description | | ?Description | ||
+ | | ?PrettySince | ||
+ | | ?PrettyRemoved | ||
}} | }} | ||
+ | == Supertypes == | ||
+ | * [[parent::Object]] | ||
+ | == Notes == | ||
+ | {{oldin|[[0.9.0]]|090|type=note|text=This method for retrieving errors has been replaced by [[Thread:getError]] and [[love.threaderror]]}} | ||
+ | If a Lua error occurs in the thread, a message with the name "error" gets pushed to its message pool. Retrieve the message with <tt>Thread:get('error')</tt>. | ||
== See Also == | == See Also == | ||
* [[parent::love.thread]] | * [[parent::love.thread]] | ||
[[Category:Types]] | [[Category:Types]] | ||
− | {{#set:Description=A Thread represents a thread. | + | {{#set:Description=A Thread represents a thread.}} |
− | }} | + | == Other Languages == |
+ | {{i18n|Thread}} |
Latest revision as of 22:34, 27 December 2015
Available since LÖVE 0.7.0 |
This type is not supported in earlier versions. |
A Thread is a chunk of code that can run in parallel with other threads. Data can be sent between different threads with Channel objects.
Constructors
love.thread.newThread | Creates a new Thread from a filename, string or FileData object containing Lua code. | 0.7.0 |
Functions
Object:release | Immediately destroys the object's Lua reference. | 11.0 | |
Object:type | Gets the type of the object as a string. | ||
Object:typeOf | Checks whether an object is of a certain type. | ||
Thread:demand | Receive a message from a thread. Wait for the message to exist before returning. | 0.7.0 | 0.9.0 |
Thread:get | Get a value. | 0.8.0 | 0.9.0 |
Thread:getError | Retrieves the error string from the thread. | 0.9.0 | |
Thread:getKeys | Returns the names of all messages as a table. | 0.8.0 | 0.9.0 |
Thread:getName | Get the name of a thread. | 0.7.0 | 0.9.0 |
Thread:isRunning | Returns whether the thread is currently running. | 0.9.0 | |
Thread:kill | Forcefully terminate the thread. | 0.7.0 | 0.8.0 |
Thread:peek | Receive a message from a thread, but leave it in the message box. | 0.7.0 | 0.9.0 |
Thread:receive | Receive a message from a thread. | 0.7.0 | 0.8.0 |
Thread:send | Send a message. | 0.7.0 | 0.8.0 |
Thread:set | Set a value. | 0.8.0 | 0.9.0 |
Thread:start | Starts the thread. | 0.7.0 | |
Thread:wait | Wait for a thread to finish. | 0.7.0 |
Supertypes
Notes
Removed in LÖVE 0.9.0 |
This method for retrieving errors has been replaced by Thread:getError and love.threaderror. |
If a Lua error occurs in the thread, a message with the name "error" gets pushed to its message pool. Retrieve the message with Thread:get('error').
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info