scansion.async: Better logging

Sat, 19 Sep 2015 21:43:35 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 19 Sep 2015 21:43:35 +0100
changeset 18
5913cc9d1b5b
parent 17
610917f3ea97
child 19
af311b9827e2

scansion.async: Better logging

scansion/async.lua file | annotate | diff | comparison | revisions
--- a/scansion/async.lua	Mon Sep 07 14:33:47 2015 +0100
+++ b/scansion/async.lua	Sat Sep 19 21:43:35 2015 +0100
@@ -1,4 +1,4 @@
---local log = require "util.logger".init("util.async");
+local log = require "verse".new_logger("util.async");
 
 local function runner_continue(thread)
 	-- ASSUMPTION: runner is in 'waiting' state (but we don't have the runner to know for sure)
@@ -16,6 +16,7 @@
 		-- If state is 'ready', it is our responsibility to update runner.state from 'waiting'.
 		-- We also have to :run(), because the queue might have further items that will not be
 		-- processed otherwise. FIXME: It's probably best to do this in a nexttick (0 timer).
+		log("debug", "Runner is ready (finished) - restarting", debug.traceback());
 		runner.state = "ready";
 		runner:run();
 	end
@@ -54,19 +55,19 @@
 		if not guard then
 			guard = {};
 			guards[id] = guard;
-			--log("debug", "New guard!");
+			log("debug", "New guard!");
 		else
 			table.insert(guard, thread);
-			--log("debug", "Guarded. %d threads waiting.", #guard)
+			log("debug", "Guarded. %d threads waiting.", #guard)
 			coroutine.yield("wait");
 		end
 		local function exit()
 			local next_waiting = table.remove(guard, 1);
 			if next_waiting then
-				--log("debug", "guard: Executing next waiting thread (%d left)", #guard)
+				log("debug", "guard: Executing next waiting thread (%d left)", #guard)
 				runner_continue(next_waiting);
 			else
-				--log("debug", "Guard off duty.")
+				log("debug", "Guard off duty.")
 				guards[id] = nil;
 			end
 		end
@@ -100,6 +101,7 @@
 end
 
 function runner_mt:run(input)
+	log("debug", "RUNNING", debug.traceback())
 	if input ~= nil then
 		table.insert(self.queue, input);
 	end

mercurial