mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-19 01:51:01 +00:00
Only notify observers once per second.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@28670 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6307bc5da8
commit
af38858926
1 changed files with 20 additions and 12 deletions
32
GSTicker.m
32
GSTicker.m
|
@ -69,6 +69,7 @@ static NSDate *startDate = nil;
|
|||
@public
|
||||
NSTimer *theTimer;
|
||||
NSMutableArray *observers;
|
||||
unsigned last;
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -306,20 +307,27 @@ NSTimeInterval GSTickerTimeNow()
|
|||
|
||||
if ([tt->observers count] > 0)
|
||||
{
|
||||
NSArray *a = [tt->observers copy];
|
||||
NSArray *a;
|
||||
unsigned tick;
|
||||
|
||||
GSTickerTimeNow();
|
||||
NS_DURING
|
||||
{
|
||||
[a makeObjectsPerformSelector: @selector(fire:)
|
||||
withObject: tt->observers];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Problem firing ticker observers: %@", localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
RELEASE(a);
|
||||
tick = GSTickerTimeTick();
|
||||
if (tick != tt->last)
|
||||
{
|
||||
tt->last = tick;
|
||||
a = [tt->observers copy];
|
||||
NS_DURING
|
||||
{
|
||||
[a makeObjectsPerformSelector: @selector(fire:)
|
||||
withObject: tt->observers];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Problem firing ticker observers: %@", localException);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
RELEASE(a);
|
||||
}
|
||||
}
|
||||
|
||||
ti = GSTickerTimeNow();
|
||||
|
|
Loading…
Reference in a new issue