further simplify and add comments

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28655 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-09-10 15:30:55 +00:00
parent 99a9887e35
commit b510b0d659

View file

@ -931,8 +931,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
*/
now = GSTimeNow();
/*
* Fire housekeeping timer as necessary
/* Fire housekeeping timer as necessary
*/
if ((t = context->housekeeper) != nil)
{
@ -949,24 +948,19 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
}
}
/* Remove invalidated timers.
*/
i = GSIArrayCount(timers);
while (i-- > 0)
{
t = GSIArrayItemAtIndex(timers, i).obj;
if (timerInvalidated(t) == YES)
{
GSIArrayRemoveItemAtIndex(timers, i);
}
}
/* Fire the oldest timer whose fire date has passed.
/* Fire the oldest/first valid timer whose fire date has passed
* and fire it.
* We fire timers in the order in which they were added to the
* run loop rather than in date order. This prevents code
* from blocking other timers by adding timers whose fire date
* is some time in the past... we guarantee fair handling.
*/
c = GSIArrayCount(timers);
for (i = 0; i < c; i++)
{
t = GSIArrayItemAtIndex(timers, i).obj;
if (timerInvalidated(t) == NO)
{
d = timerDate(t);
ti = [d timeIntervalSinceReferenceDate];
if (ti < now)
@ -979,7 +973,8 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
{
/* Updated ... replace in array.
*/
GSIArrayAddItemNoRetain(timers, (GSIArrayItem)((id)t));
GSIArrayAddItemNoRetain(timers,
(GSIArrayItem)((id)t));
}
else
{
@ -992,8 +987,11 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
break;
}
}
}
/* Now, find the earliest fire date.
/* Now, find the earliest remaining timer date while removing
* any invalidated timers. We iterate from the end of the
* array to minimise the amount of array alteration needed.
*/
earliest = nil;
i = GSIArrayCount(timers);