mirror of
https://github.com/edmccard/twoapple-reboot.git
synced 2024-12-22 11:29:58 +00:00
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)
|
||||
{
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user