1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
local DEFAULT_EXPIRATION_INTERVAL_MS = 5000
local DEFAULT_EXTENSION_INTERVAL_MS = 5000
-- Tracks the number of occurrences of each value within an indeterminate set using a sliding time window.
end
end
end
end
end
-- Note: Expiration should only be set by the owning ZO_RecurrenceTracker
-- instance to optimize the maintenance for value expiration and removal.
end
end
-- expirationIntervalMS = the initial lifetime for new values.
-- extensionIntervalMS = how long an existing value's lifetime should be extended for subsequent occurrences.
end
-- Ignore nil values.
return
end
-- Perform clean up only when necessary.
local expirationMS = nil
if valueEntry then
-- Increment the number of occurrences.
numOccurrences = numOccurrences + 1
-- Extend the expiration time to the maximum of either the current expiration time or now + m_extensionIntervalMS.
else
-- Add the new value entry.
end
-- Update the next expiration to this expiration.
end
end
-- Returns the number of unexpired occurrences for the specified value.
end
-- Returns the number of unexpired values (not occurrences).
-- Perform clean up only when necessary.
end
-- Returns a reference to the specified value entry object if the value
-- exists and has not yet expired.
-- This entry has already expired; remove it and return nil.
valueEntry = nil
end
return valueEntry
end
-- Returns true if the specified value exists and has not yet expired.
return valueEntry ~= nil
end
-- Removes and returns the specified value if it exists and has not yet expired.
if valueEntry then
end
return valueEntry
end
-- Removes all values.
end
-- Performs internal maintenance for value expiration and removal.
-- Note: It should not be necessary to call this externally; the
-- tracker performs maintenance automatically when necessary.
-- There are no values pending expiration.
return
end
-- There are no values that have expired.
return
end
-- Remove expired values and identify the next upcoming value expiration time.
local nextExpirationMS = nil
if expirationMS <= currentTimeMS then
-- Remove the expired value.
elseif not nextExpirationMS or expirationMS < nextExpirationMS then
-- Track the next upcoming expiration time.
nextExpirationMS = expirationMS
end
end
-- Track the next upcoming value expiration to avoid unnecessary maintenance.
end |