summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/WaitQueue.lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-03-27 16:38:45 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-03-27 16:38:45 -0400
commitaf38e606865c2ed49a13bd6bd91d9604997798c8 (patch)
treedd28e7694eee4ab8bd71415171a6a056672b4cde /indra/newview/scripts/lua/WaitQueue.lua
parent58d5e288e0bfaa9819b68b376767a8a39a97fef8 (diff)
Enhance Lua debugging output.
Don't use "debug" as the name of a function to conditionally write debug messages: "debug" is a Luau built-in library, and assigning that name locally would shadow the builtin. Use "dbg" instead. Recast fiber.print_all() as fiber.format_all() that returns a string; then print_all() is simply print(format_all()). This refactoring allows us to use dbg(format_all()) as well. Add a couple new dbg() messages at fiber state changes.
Diffstat (limited to 'indra/newview/scripts/lua/WaitQueue.lua')
-rw-r--r--indra/newview/scripts/lua/WaitQueue.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/indra/newview/scripts/lua/WaitQueue.lua b/indra/newview/scripts/lua/WaitQueue.lua
index 1fbcc50847..ad4fdecf43 100644
--- a/indra/newview/scripts/lua/WaitQueue.lua
+++ b/indra/newview/scripts/lua/WaitQueue.lua
@@ -5,8 +5,8 @@
local fiber = require('fiber')
local Queue = require('Queue')
--- local debug = LL.print_debug
-local function debug(...) end
+-- local dbg = require('printf')
+local function dbg(...) end
local WaitQueue = Queue:new()
@@ -60,17 +60,18 @@ function WaitQueue:Dequeue()
-- the queue while there are still items left, and we want the
-- consumer(s) to retrieve those last few items.
if self._closed then
- debug('WaitQueue:Dequeue(): closed')
+ dbg('WaitQueue:Dequeue(): closed')
return nil
end
- debug('WaitQueue:Dequeue(): waiting')
+ dbg('WaitQueue:Dequeue(): waiting')
-- add the running coroutine to the list of waiters
+ dbg('WaitQueue:Dequeue() running %s', tostring(coroutine.running() or 'main'))
table.insert(self._waiters, fiber.running())
-- then let somebody else run
fiber.wait()
end
-- here we're sure this queue isn't empty
- debug('WaitQueue:Dequeue() calling Queue.Dequeue()')
+ dbg('WaitQueue:Dequeue() calling Queue.Dequeue()')
return Queue.Dequeue(self)
end