diff --git a/computercraft/sigils.lua b/computercraft/sigils.lua index 61cea73..df89959 100644 --- a/computercraft/sigils.lua +++ b/computercraft/sigils.lua @@ -4,7 +4,6 @@ local Pipe = require('sigils.pipe') local WebSocket = require('sigils.websocket') local Utils = require('sigils.utils') local Logging = require('sigils.logging') -local Concurrent = require('sigils.concurrent') local DEFAULT_SERVER_URL = 'wss://sigils.fredchan.org' @@ -82,7 +81,6 @@ local function init () function () WebSocket.doWebSocket(wsContext) end, function () Controller.listenForCcpipesEvents(wsContext, factory) end, function () Pipe.processAllPipesForever(factory) end, - function () Concurrent.default_runner.run_forever() end, function () waitForQuitKey(wsContext) end, function () while true do os.sleep(0.05) end end -- forces the OS not to lock up ) diff --git a/computercraft/sigils/ItemDetailAndLimitCache.lua b/computercraft/sigils/ItemDetailAndLimitCache.lua index a917538..fa2508f 100644 --- a/computercraft/sigils/ItemDetailAndLimitCache.lua +++ b/computercraft/sigils/ItemDetailAndLimitCache.lua @@ -30,7 +30,6 @@ function ItemDetailAndLimitCache.new (missingPeriphs, initialMap) ---@param groups Group[] List of groups to fulfill item limits and details for function o:Fulfill(groups) local runner = Concurrent.default_runner - local parallelTasks = {} for _, group in pairs(groups) do for _, slot in pairs(group.slots) do @@ -42,8 +41,7 @@ function ItemDetailAndLimitCache.new (missingPeriphs, initialMap) end -- fulfill itemDetail - table.insert( - parallelTasks, + runner.spawn( function () local periph = peripheral.wrap(slot.periphId) if periph and o.map[slotId].itemDetail == nil then @@ -54,8 +52,7 @@ function ItemDetailAndLimitCache.new (missingPeriphs, initialMap) ) -- fulfill itemLimit - table.insert( - parallelTasks, + runner.spawn( function () local periph = peripheral.wrap(slot.periphId) if periph and o.map[slotId].itemLimit == nil then @@ -68,7 +65,7 @@ function ItemDetailAndLimitCache.new (missingPeriphs, initialMap) end end - runner.await_batch_tasks(parallelTasks) + runner.run_until_done() end ---Get the item limit of the given Slot diff --git a/computercraft/sigils/concurrent.lua b/computercraft/sigils/concurrent.lua index 2d23da6..e966959 100644 --- a/computercraft/sigils/concurrent.lua +++ b/computercraft/sigils/concurrent.lua @@ -110,22 +110,6 @@ local function create_runner(max_size) end end - ---Run an array of functions in parallel and wait for all of them to finish - ---@param fns function[] List of functions to wait for the completion of - function await_batch_tasks(fns) - local awaits = {} - for _, task in pairs(fns) do - local resolve, await = create_future() - table.insert(awaits, await) - spawn(function () - task() - resolve() - end) - end - - parallel.waitForAll(table.unpack(awaits)) - end - --- A coroutine executor. -- @type Runner return { @@ -133,7 +117,6 @@ local function create_runner(max_size) has_work = has_work, run_until_done = run_until_done, run_forever = run_forever, - await_all_tasks = await_all_tasks, } end