Difference between revisions of "X Threads"

From GiderosMobile
Line 9: Line 9:
 
<translate>The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.
 
<translate>The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.
 
</translate><br/>
 
</translate><br/>
 
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
  
Line 28: Line 27:
  
 
=== <translate>Methods</translate> ===
 
=== <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.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: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. -->
+
[[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;"|
 
| style="width: 50%; vertical-align:top;"|
=== blah ===
 
 
|}
 
|}

Revision as of 17:24, 14 September 2018


Supported platforms: Platform android.pngPlatform ios.pngPlatform pc.pngPlatform mac.pngPlatform winrt.pngPlatform win32.png

Available since: 2018.12

Description

The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.

Examples

Simple example of one thread sleeping

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")

Methods

Thread.new Create a new thread
Thread:setFunction Sets Lua function that thread will execute.
Thread:getNumLogicalCores Returns number of logical cores on host machine.