Difference between revisions of "X Threads"
From GiderosMobile
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
=== Description === | === 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. | The '''Threads''' plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available. | ||
=== Example === | === Example === | ||
'''Simple example of getting result from a thread''' | '''Simple example of getting result from a thread''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
require "Threads" | require "Threads" | ||
local thread = Thread.new() | local thread = Thread.new() | ||
Line 25: | Line 28: | ||
end | end | ||
print("woot!") | print("woot!") | ||
− | </ | + | </syntaxhighlight> |
=== Class === | === Class === |
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