|
|
Line 1: |
Line 1: |
− | __NOTOC__
| |
− | <languages />
| |
− | <!-- GIDEROSOBJ:Threads -->
| |
− | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform pc.png]][[File:Platform mac.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
| |
− | <br/>
| |
− | '''<translate>Available since</translate>:''' 2018.12<br/>
| |
− | <br/>
| |
− | === <translate>Description</translate> ===
| |
− | <translate>The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.
| |
− | </translate><br/>
| |
− | === <translate>Examples</translate> ===
| |
| | | |
− | '''Simple example of one thread sleeping'''<br/>
| |
− | <source lang="lua">require "Threads"
| |
− | local thread = Thread.new()
| |
− | thread:setFunction(function() Thread.sleepFor(100000) end)
| |
− | thread:execute()
| |
− | local ok = false
| |
− | while not ok do
| |
− | ok = thread:getResult()
| |
− | end
| |
− | print("woot")
| |
− | </source>
| |
− |
| |
− | {|-
| |
− | | style="width: 50%; vertical-align:top;"|
| |
− |
| |
− | === <translate>Methods</translate> ===
| |
− | [[Special:MyLanguage/Thread.new|Thread.new]] ''<translate>Create a new thread</translate>''<br/><!-- GIDEROSMTD:Thread.new() Create a new thread -->
| |
− | [[Special:MyLanguage/Thread:setFunction|Thread:setFunction]] ''<translate>Sets Lua function that thread will execute.</translate>''<br/><!-- GIDEROSMTD:Thread:setFunction() Sets Lua function that thread will execute. -->
| |
− | [[Special:MyLanguage/Thread:getNumLogicalCores|Thread:getNumLogicalCores]] ''<translate>Returns number of logical cores on host machine.</translate>''<br/><!-- GIDEROSMTD:Thread:getNumLogicalCores() Returns number of logical cores on host machine. -->
| |
− | | style="width: 50%; vertical-align:top;"|
| |
− | |}
| |