# HG changeset patch # User Matthew Wild # Date 1442695415 -3600 # Node ID 5913cc9d1b5bd360281ad9359094144837069973 # Parent 610917f3ea97db3f183cb16e425f0cd96635d757 scansion.async: Better logging diff -r 610917f3ea97 -r 5913cc9d1b5b scansion/async.lua --- 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