From 94743e963352cb76d78c84649fbc2dd88ddaaaf8 Mon Sep 17 00:00:00 2001 From: osmarks Date: Fri, 27 Jul 2018 09:47:57 +0100 Subject: [PATCH] Parallelize (ish; CC can't do much of that) indexing --- backend-chests.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend-chests.lua b/backend-chests.lua index 25564ab..b78b04d 100644 --- a/backend-chests.lua +++ b/backend-chests.lua @@ -108,12 +108,18 @@ local function server(command) if command.type == "buffers" then -- Sends the external address of the buffer return conf.buffer_external elseif command.type == "reindex" then - update_index() + os.queueEvent "reindex" elseif command.type == "extract" then local result = find_by_ID_meta(command.ID, command.meta) end end -update_index() +local function indexer_thread() + while true do + update_index() + os.pullEvent "reindex" + end +end + w.init() -w.serve(server, "storage") \ No newline at end of file +parallel.waitForAll(function() w.serve(server, "storage") end, indexer_thread) \ No newline at end of file