/branches/zhTW_201107/Aloft/Libs/AceTimer-3.0
-- make into AceTimer. |
-- @class file |
-- @name AceTimer-3.0 |
-- @release $Id: AceTimer-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
-- @release $Id: AceTimer-3.0.lua 1037 2011-09-02 16:24:08Z mikk $ |
--[[ |
Basic assumptions: |
- ALLOWS unscheduling ANY timer (including the current running one) at any time, including during OnUpdate processing |
]] |
local MAJOR, MINOR = "AceTimer-3.0", 5 |
local MAJOR, MINOR = "AceTimer-3.0", 6 |
local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceTimer then return end -- No upgrade needed |
-- Time to clean it out? |
local list = selfs[self] |
if (list.__ops or 0) < 250 then -- 250 slosh indices = ~10KB wasted (max!). For one 'self'. |
if (list.__ops or 0) < 250 then -- 250 slosh indices = ~10KB wasted (worst case!). For one 'self'. |
return |
end |
local n=0 |
for k,v in pairs(list) do |
newlist[k] = v |
n=n+1 |
if type(v)=="table" and v.callback then -- if the timer is actually live: count it |
n=n+1 |
end |
end |
newlist.__ops = 0 -- Reset operation count |
AceTimer.frame:SetScript("OnEvent", OnEvent) |
AceTimer.frame:RegisterEvent("PLAYER_REGEN_ENABLED") |
-- In theory, we should hide&show the frame based on there being timers or not. |
-- In theory, we could hide&show the frame based on there being timers or not. |
-- However, this job is fairly expensive, and the chance that there will |
-- actually be zero timers running is diminuitive to say the lest. |
-- actually be zero timers running is diminuitive to say the least. |