Difference between revisions of "X Threads"
From GiderosMobile
(Created page with "__NOTOC__ <languages /> <!-- GIDEROSOBJ:Threads --> '''<translate>Supported platforms</translate>:''' File:Platform android.pngFile:Platform ios.pngFile:Platform pc....") |
|||
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | |||
<!-- GIDEROSOBJ:Threads --> | <!-- GIDEROSOBJ:Threads --> | ||
− | ''' | + | '''Supported platforms:''' [[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/> | + | '''Available since:''' 2018.10<br/> |
− | ''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''Simple example of | + | === Description === |
− | < | + | |
+ | '''!!! THE THREAD PLUGIN WAS DEPRECATED IN GIDEROS 2022.10 !!!''' | ||
+ | |||
+ | The '''Threads''' plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available. | ||
+ | |||
+ | === Example === | ||
+ | '''Simple example of getting result from a thread''' | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | require "Threads" | ||
local thread = Thread.new() | local thread = Thread.new() | ||
− | thread:setFunction(function() | + | thread:setFunction(function() |
+ | local a = 0 | ||
+ | for i = 1, 10000000 do | ||
+ | a += 1 | ||
+ | end | ||
+ | return i | ||
+ | end) | ||
thread:execute() | thread:execute() | ||
local ok = false | local ok = false | ||
while not ok do | while not ok do | ||
− | + | ok = thread:getResult() | |
end | end | ||
− | print("woot") | + | print("woot!") |
− | </ | + | </syntaxhighlight> |
− | + | === Class === | |
− | + | [[Thread]]<br/> | |
− | + | {{Thread}} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 05:06, 7 June 2025
Supported platforms:
Available since: 2018.10
Description
!!! THE THREAD PLUGIN WAS DEPRECATED IN GIDEROS 2022.10 !!!
The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.
Example
Simple example of getting result from a thread
require "Threads"
local thread = Thread.new()
thread:setFunction(function()
local a = 0
for i = 1, 10000000 do
a += 1
end
return i
end)
thread:execute()
local ok = false
while not ok do
ok = thread:getResult()
end
print("woot!")
Class