diff core.lua @ 40:dc3a66688e50

More debug message tweaks. Put comm and loot caches on separate-but-related expirations; comm is now a bit shorter and loot is now a bit longer. Check cache expirations more often (possibly revert this).
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 30 Dec 2011 21:29:44 +0000
parents 8f7ec6ccf5e3
children d6b8858c1b64
line wrap: on
line diff
--- a/core.lua	Thu Dec 29 23:15:51 2011 +0000
+++ b/core.lua	Fri Dec 30 21:29:44 2011 +0000
@@ -86,7 +86,7 @@
 	--['heirloom'] = 7,
 }
 local my_name				= UnitName('player')
-local comm_cleanup_ttl		= 5   -- seconds in the cache
+local comm_cleanup_ttl		= 4   -- seconds in the cache
 local revision_large		= nil -- defaults to 1, possibly changed by revision
 local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s, g_LOOT_ITEM_SELF_MULTIPLE_ss
 
@@ -305,7 +305,7 @@
 			local fifo = c.fifo
 			local active = #fifo > 0
 			while (#fifo > 0) and (now - fifo[1].t > c.ttl) do
-				addon.dprint('cache', name, "cache removing",fifo[1].t, fifo[1].m)
+				addon.dprint('cache', name, "cache removing", fifo[1].t, "<", fifo[1].m, ">")
 				tremove(fifo,1)
 			end
 			if active and #fifo == 0 and c.func then
@@ -315,10 +315,11 @@
 			alldone = alldone and (#fifo == 0)
 		end
 		if alldone then
-			addon.dprint('cache',"OnLoop finishing animation group")
+			addon.dprint('cache',"OnLoop FINISHING animation group")
 			cleanup_group:Finish()
+		else
+			addon.dprint('cache',"OnLoop done, not yet finished")
 		end
-		addon.dprint('cache',"OnLoop done")
 	end)
 
 	local function _add (cache, x)
@@ -326,16 +327,16 @@
 		cache.hash[x] = datum
 		tinsert (cache.fifo, datum)
 		if not cleanup_group:IsPlaying() then
-			addon.dprint('cache', cache.name, "STARTING animation group")
-			cache.cleanup:SetDuration(2)  -- hmmm
+			addon.dprint('cache', cache.name, "with entry", datum.t, "<", datum.x, "> STARTING animation group")
+			cache.cleanup:SetDuration(1)  -- hmmm
 			cleanup_group:Play()
 		end
 	end
 	local function _test (cache, x)
+		-- FIXME This can return false positives, if called after the onloop
+		-- fifo has been removed but before the GC has removed the weak entry.
+		-- What to do, what to do...
 		return cache.hash[x] ~= nil
-		--[[for _,v in ipairs(cache) do
-			if v.m == x then return true end
-		end]]
 	end
 
 	function create_new_cache (name, ttl, on_alldone)
@@ -721,7 +722,7 @@
 		end
 		table.wipe(candidates)
 	end
-	addon.recent_loot = create_new_cache ('loot', comm_cleanup_ttl, prefer_local_loots)
+	addon.recent_loot = create_new_cache ('loot', comm_cleanup_ttl+3, prefer_local_loots)
 
 	local GetItemInfo, GetItemIcon = GetItemInfo, GetItemIcon
 
@@ -1958,7 +1959,8 @@
 		self.dprint('comm', ":OCR from", sender, "message is", msg)
 
 		if self.recent_messages:test(msg) then
-			return self.dprint('cache', "message <",msg,"> already in cache, skipping")
+			self.dprint('cache', "OCR message <",msg,"> already in cache, skipping")
+			return
 		end
 		self.recent_messages:add(msg)