4 local function handle_job(jobid, serialized_retval)
5 local retval = core.deserialize(serialized_retval)
6 assert(type(core.async_jobs[jobid]) == "function")
7 core.async_jobs[jobid](retval)
8 core.async_jobs[jobid] = nil
11 if core.register_globalstep then
12 core.register_globalstep(function(dtime)
13 for i, job in ipairs(core.get_finished_jobs()) do
14 handle_job(job.jobid, job.retval)
18 core.async_event_handler = handle_job
21 function core.handle_async(func, parameter, callback)
23 local serialized_func = string.dump(func)
25 assert(serialized_func ~= nil)
27 -- Serialize parameters
28 local serialized_param = core.serialize(parameter)
30 if serialized_param == nil then
34 local jobid = core.do_async_callback(serialized_func, serialized_param)
36 core.async_jobs[jobid] = callback