Garbage collect deactivated timers when they are added faster than they can be triggered.

This commit is contained in:
edmccard 2012-04-30 22:30:23 -04:00
parent 22b32fc348
commit 2c404c68a2

View File

@ -147,6 +147,19 @@ public:
final size_t addCounter(uint length, bool delegate() expiry)
{
if (nextFree == counters.length)
{
size_t idx = head;
size_t prev = -1;
while (idx != -1)
{
if (!counters[idx].active)
deleteCounter(idx, prev);
else
prev = idx;
idx = counters[idx].next;
}
}
if (nextFree == counters.length)
{
counters.length += 20;