BlockColor-Engine/builtin/async/init.lua

18 lines
432 B
Lua
Raw Normal View History

2014-04-27 23:55:49 +02:00
2015-11-01 09:01:13 +01:00
core.log("info", "Initializing Asynchronous environment")
2014-04-27 23:55:49 +02:00
2015-11-01 09:01:13 +01:00
function core.job_processor(serialized_func, serialized_param)
2014-04-27 23:55:49 +02:00
local func = loadstring(serialized_func)
2015-11-01 09:01:13 +01:00
local param = core.deserialize(serialized_param)
2014-04-27 23:55:49 +02:00
local retval = nil
if type(func) == "function" then
2015-11-01 09:01:13 +01:00
retval = core.serialize(func(param))
2014-04-27 23:55:49 +02:00
else
2015-11-01 09:01:13 +01:00
core.log("error", "ASYNC WORKER: Unable to deserialize function")
2014-04-27 23:55:49 +02:00
end
2015-11-01 09:01:13 +01:00
return retval or core.serialize(nil)
2014-04-27 23:55:49 +02:00
end