# HG changeset patch # User jbe # Date 1431048932 -7200 # Node ID 1939ffe973e04e46686799ed8c072ac5932e0b9a # Parent b0e2fbf9d5a8a6a61345dfeb3cc0408023a0000b Improved Lua reference code for moonbridge_io.run(...) diff -r b0e2fbf9d5a8 -r 1939ffe973e0 reference.txt --- a/reference.txt Fri May 08 03:22:15 2015 +0200 +++ b/reference.txt Fri May 08 03:35:32 2015 +0200 @@ -384,26 +384,29 @@ local work_to_do = false for func, result_handler in pairs(function_set) do ::again:: - local r1, r2, r3, ... = func() - if r1 == moonbridge_io.block then - if type(r3) == "string" and string.match(r3, "r") then - read_fds[r2] = true + local res = table.pack(func()) + if res[1] == moonbridge_io.block then + if string.match(res[3], "r") then + read_fds[res[2]] = true end - if type(r3) == "string" and string.match(r3, "w") then - write_fds[r2] = true + if string.match(res[3], "w") then + write_fds[res[2]] = true end work_to_do = true - elseif r1 == moonbridge_io.multiblock then - for fd, active in pairs(r2) do + elseif res[1] == moonbridge_io.multiblock then + for fd, active in pairs(res[2]) do if active then read_fds[fd] = true end end - for fd, active in pairs(r3) do + for fd, active in pairs(res[3]) do if active then write_fds[fd] = true end end work_to_do = true else - if result_handler == true or result_handler(r1, r2, r3, ...) then - function_set[func] = nil + if + result_handler == true or + result_handler(table.unpack(res, 1, res.n)) + then + function_set[func] = nil -- task finished else goto again end