Re: NSTimer "takes over" CPU everytime it repeats?
Re: NSTimer "takes over" CPU everytime it repeats?
- Subject: Re: NSTimer "takes over" CPU everytime it repeats?
- From: James DiPalma <email@hidden>
- Date: Sat, 26 Oct 2002 16:54:49 -0700
From: Cameron Hayne <email@hidden>
And by the way, it is slightly misleading to say that your "timer
takes over
the CPU" - it isn't the timer but rather the code that is executed
when the
timer fires that is taking over the CPU.
If you look at Hisaoki's timer, it might just be his timer that takes
over the CPU.
From: Hisaoki Nishida <email@hidden>
selectTimer = [[NSTimer scheduledTimerWithTimeInterval:0.0
target:self selector:@selector(run)
userInfo:nil repeats:YES] retain];
I created an NSTimer just like this and called a method that does
nothing and my sample app doing nothing but fire this timer in a
background thread took over 50% of my CPU. Ondra's suggestion of adding
a small time interval might help.
I don't understand Douglas Davidson's suggestion:
it sounds rather like polling. It would be better, if possible, to
use a run loop source instead.
Documentation for NSRunLoop says, "An NSRunLoop processes input for
sources such as mouse and keyboard events from the window system,
NSPorts, NSTimers, and NSConnections."
-jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.