X Threads

From GiderosMobile
Revision as of 18:20, 14 September 2018 by PaulR (talk | contribs) (Created page with "__NOTOC__ <languages /> <!-- GIDEROSOBJ:Threads --> '''<translate>Supported platforms</translate>:''' File:Platform android.pngFile:Platform ios.pngFile:Platform pc....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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

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

blah