summaryrefslogtreecommitdiff
path: root/builtin/async_env.lua
blob: afc69219ce7bfe75254296283eb4cd4e12e9a7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
engine.log("info","Initializing Asynchronous environment")

dofile(SCRIPTDIR .. DIR_DELIM .. "misc_helpers.lua")

function engine.job_processor(serialized_function, serialized_data)

	local fct = marshal.decode(serialized_function)
	local params = marshal.decode(serialized_data)
	local retval = marshal.encode(nil)

	if fct ~= nil and type(fct) == "function" then
		local result = fct(params)
		retval = marshal.encode(result)
	else
		engine.log("error","ASYNC WORKER: unable to deserialize function")
	end

	return retval,retval:len()
end