From 2e66aca35722e7fee786027d545fe371786fc01f Mon Sep 17 00:00:00 2001 From: sapier Date: Tue, 26 Nov 2013 18:15:31 +0100 Subject: Fix modstore/favourites hang by adding asynchronous lua job support --- builtin/async_env.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 builtin/async_env.lua (limited to 'builtin/async_env.lua') diff --git a/builtin/async_env.lua b/builtin/async_env.lua new file mode 100644 index 000000000..afc69219c --- /dev/null +++ b/builtin/async_env.lua @@ -0,0 +1,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 -- cgit v1.2.3