2014-04-15 19:41:07 +02:00
|
|
|
engine.log("info", "Initializing Asynchronous environment")
|
|
|
|
local tbl = engine or minetest
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2014-04-15 19:41:07 +02:00
|
|
|
minetest = tbl
|
|
|
|
dofile(SCRIPTDIR .. DIR_DELIM .. "serialize.lua")
|
2013-11-26 18:15:31 +01:00
|
|
|
dofile(SCRIPTDIR .. DIR_DELIM .. "misc_helpers.lua")
|
|
|
|
|
2014-04-15 19:41:07 +02:00
|
|
|
function tbl.job_processor(serialized_func, serialized_param)
|
|
|
|
local func = loadstring(serialized_func)
|
|
|
|
local param = tbl.deserialize(serialized_param)
|
|
|
|
local retval = nil
|
2013-11-26 18:15:31 +01:00
|
|
|
|
2014-04-15 19:41:07 +02:00
|
|
|
if type(func) == "function" then
|
|
|
|
retval = tbl.serialize(func(param))
|
2013-11-26 18:15:31 +01:00
|
|
|
else
|
2014-04-15 19:41:07 +02:00
|
|
|
tbl.log("error", "ASYNC WORKER: Unable to deserialize function")
|
2013-11-26 18:15:31 +01:00
|
|
|
end
|
|
|
|
|
2014-04-15 19:41:07 +02:00
|
|
|
return retval or tbl.serialize(nil)
|
2013-11-26 18:15:31 +01:00
|
|
|
end
|
2014-04-15 19:41:07 +02:00
|
|
|
|