Skip to content

Commit da37767

Browse files
committed
fix(multithreading): support new lane:join() API
1 parent 6fc4af9 commit da37767

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/luacheck/multithreading.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-- luacheck: push compat
2+
local unpack = table.unpack or unpack
3+
-- luacheck: pop
4+
15
local utils = require "luacheck.utils"
26

37
local multithreading = {}
@@ -90,7 +94,20 @@ function multithreading.pmap(func, array, jobs)
9094
local results = {}
9195

9296
for _, worker in ipairs(workers) do
93-
local _, ok, worker_results = assert(worker:join())
97+
local join_results = {worker:join()}
98+
99+
-- Manage both new and old lane:join() API formats.
100+
-- See https://github.com/LuaLanes/lanes/commit/bfdc7a92c4e3e99522abb6d90ef2cbb021f36fc8
101+
local ok, worker_results, _
102+
if #join_results == 4 then
103+
-- New API: {true, _, ok, worker_results}
104+
_, _, ok, worker_results = unpack(join_results)
105+
elseif #join_results == 3 then
106+
-- Old API: {true, ok, worker_results}
107+
_, ok, worker_results = unpack(join_results)
108+
else
109+
error("Unexpected lane:join() return format", 0)
110+
end
94111

95112
if ok then
96113
utils.update(results, worker_results)

0 commit comments

Comments
 (0)