Garbage collect deactivated timers when they are added faster than they can be triggered.
This commit is contained in:
parent
22b32fc348
commit
2c404c68a2
13
src/timer.d
13
src/timer.d
|
@ -147,6 +147,19 @@ public:
|
||||||
|
|
||||||
final size_t addCounter(uint length, bool delegate() expiry)
|
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)
|
if (nextFree == counters.length)
|
||||||
{
|
{
|
||||||
counters.length += 20;
|
counters.length += 20;
|
||||||
|
|
Loading…
Reference in New Issue