From 11723cffe011e99c1092388958fb1a047ab1c09c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 15 May 2020 16:38:19 +0200 Subject: builtin: Move common/async_event.lua to mainmenu/async_event.lua It only works in the context of the mainmenu. --- builtin/common/async_event.lua | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 builtin/common/async_event.lua (limited to 'builtin/common/async_event.lua') diff --git a/builtin/common/async_event.lua b/builtin/common/async_event.lua deleted file mode 100644 index 988af79b9..000000000 --- a/builtin/common/async_event.lua +++ /dev/null @@ -1,40 +0,0 @@ - -core.async_jobs = {} - -local function handle_job(jobid, serialized_retval) - local retval = core.deserialize(serialized_retval) - assert(type(core.async_jobs[jobid]) == "function") - core.async_jobs[jobid](retval) - core.async_jobs[jobid] = nil -end - -if core.register_globalstep then - core.register_globalstep(function(dtime) - for i, job in ipairs(core.get_finished_jobs()) do - handle_job(job.jobid, job.retval) - end - end) -else - core.async_event_handler = handle_job -end - -function core.handle_async(func, parameter, callback) - -- Serialize function - local serialized_func = string.dump(func) - - assert(serialized_func ~= nil) - - -- Serialize parameters - local serialized_param = core.serialize(parameter) - - if serialized_param == nil then - return false - end - - local jobid = core.do_async_callback(serialized_func, serialized_param) - - core.async_jobs[jobid] = callback - - return true -end - -- cgit v1.2.3