1+ -- luacheck: push compat
2+ local unpack = table.unpack or unpack
3+ -- luacheck: pop
4+
15local utils = require " luacheck.utils"
26
37local multithreading = {}
@@ -12,6 +16,8 @@ if not lanes_ok then
1216 return multithreading
1317end
1418
19+ local lanes_major = tonumber (lanes .ABOUT .version :match (" ^(%d+)" ))
20+
1521local cpu_number_detection_commands = {}
1622
1723if utils .is_windows then
@@ -90,7 +96,18 @@ function multithreading.pmap(func, array, jobs)
9096 local results = {}
9197
9298 for _ , worker in ipairs (workers ) do
93- local _ , ok , worker_results = assert (worker :join ())
99+ local join_results = {worker :join ()}
100+
101+ -- Manage both new and old lane:join() API formats.
102+ -- See https://github.com/LuaLanes/lanes/commit/bfdc7a92c4e3e99522abb6d90ef2cbb021f36fc8
103+ local ok , worker_results , _
104+ if lanes_major >= 4 then
105+ -- New API: {true, _, ok, worker_results}
106+ _ , _ , ok , worker_results = unpack (join_results )
107+ else
108+ -- Old API: {true, ok, worker_results}
109+ _ , ok , worker_results = unpack (join_results )
110+ end
94111
95112 if ok then
96113 utils .update (results , worker_results )
0 commit comments