aboutsummaryrefslogtreecommitdiff
path: root/builtin/async_env.lua
blob: cdcb82ee37db4ff30f600f24604e395669a2d025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
engine.log("info", "Initializing Asynchronous environment")
local tbl = engine or minetest

minetest = tbl
dofile(SCRIPTDIR .. DIR_DELIM .. "serialize.lua")
dofile(SCRIPTDIR .. DIR_DELIM .. "misc_helpers.lua")

function tbl.job_processor(serialized_func, serialized_param)
	local func = loadstring(serialized_func)
	local param = tbl.deserialize(serialized_param)
	local retval = nil

	if type(func) == "function" then
		retval = tbl.serialize(func(param))
	else
		tbl.log("error", "ASYNC WORKER: Unable to deserialize function")
	end

	return retval or tbl.serialize(nil)
end