Added support to pass extra arguments to functions on core.add_thread

This commit is contained in:
Dheisom Gomes 2022-01-28 11:53:30 -03:00
parent 456126400a
commit 8c0685d440
1 changed files with 4 additions and 2 deletions

View File

@ -953,9 +953,11 @@ function core.show_title_bar(show)
end
function core.add_thread(f, weak_ref)
function core.add_thread(f, weak_ref, ...)
local key = weak_ref or #core.threads + 1
local fn = function() return core.try(f) end
local args = {...}
local unpack = unpack or table.unpack
local fn = function() return core.try(f, unpack(args)) end
core.threads[key] = { cr = coroutine.create(fn), wake = 0 }
return key
end