Change how the timer is dispatched based on the threadedness of the

application.
This commit is contained in:
Empathic Qubit 2021-05-01 21:25:38 -04:00
parent 836fc09ce8
commit aa8d27959c
3 changed files with 19 additions and 11 deletions

View file

@ -3,12 +3,6 @@ local callback, set_timer_timeout = callback, set_timer_timeout
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
local Promise = dofile(base.."/promise.lua")
-- Only the parent should manage ticks!
callback.register('timer', function()
Promise.update()
set_timer_timeout(1)
end)
set_timer_timeout(1)
local config = dofile(base.."/config.lua")
local util = dofile(base.."/util.lua")(Promise)
@ -18,6 +12,21 @@ local libDeflate = dofile(base.."/LibDeflate.lua")
local hasThreads =
not util.isWin and
config.NeatConfig.Threads > 1
-- Only the parent should manage ticks!
-- I'm not terribly thrilled with this logic
if hasThreads then
callback.register('timer', function()
Promise.update()
set_timer_timeout(1)
end)
set_timer_timeout(1)
else
callback.register('input', function()
Promise.update()
end)
end
local Runner = nil
if hasThreads then
local warn = '========== When using threads, the ROM file to use comes from config.lua. Also, you do not need to start any ROM in the parent process.'

View file

@ -4,11 +4,9 @@ local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
local Promise = dofile(base.."/promise.lua")
-- Only the parent should manage ticks!
callback.register('timer', function()
callback.register('input', function()
Promise.update()
set_timer_timeout(1)
end)
set_timer_timeout(1)
local Runner = dofile(base.."/runner.lua")
local serpent = dofile(base.."/serpent.lua")

View file

@ -2,9 +2,12 @@ local gui, input, movie, settings, exec, callback, set_timer_timeout = gui, inpu
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1")
local Promise = nil
local config = dofile(base.."/config.lua")
local game = dofile(base.."/game.lua")
local mathFunctions = dofile(base.."/mathFunctions.lua")
local util = dofile(base.."/util.lua")()
local Inputs = config.InputSize+1
local Outputs = #config.ButtonNames
@ -12,8 +15,6 @@ local Outputs = #config.ButtonNames
local guiWidth = 0
local guiHeight = 0
local Promise = nil
local function message(_M, msg, color)
if color == nil then
color = 0x00009900