From 59a9ec907fba6c6ff1512bec636b82dac286d675 Mon Sep 17 00:00:00 2001 From: holly Date: Sun, 15 Aug 2021 11:32:38 +0100 Subject: [PATCH] cleanup --- server/chunkManager.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/server/chunkManager.js b/server/chunkManager.js index be63b03..970c8a1 100644 --- a/server/chunkManager.js +++ b/server/chunkManager.js @@ -20,20 +20,22 @@ module.exports = class { this.toRemove = []; + // WoAh!!! Thread pool in js!?!??!???!11!?!?! for (let i = 0; i < config.threadPoolCount; i++) { const worker = new Worker(workerPath); this.threadPool.push([false, worker]); const myID = i; worker.on("message", (data) => { - /*const user = global.getUserByKey(message[0]); - for (let square of message[1]) { user.chunksToSend.add(Buffer.from(square)); } - this.threadPool[myID][0] = false; - this.toRemove.push(message[2]);*/ switch (data[0]) { case "chunk": const user = global.getUserByKey(data[2]); user.chunksToSend.add(Buffer.from(data[1])); - //this.threadPool[myID][0] = false; + break; + + // Specific to the chunk task as multiple of them are sent before removal + case "remove": + this.toRemove.push(data[1]); + this.threadPool[myID][0] = false; break; case "generate": @@ -41,11 +43,6 @@ module.exports = class { this.toRemove.push(data[4]); this.threadPool[myID][0] = false; break; - - case "remove": - this.toRemove.push(data[1]); - this.threadPool[myID][0] = false; - break; } }); }