Re: Giving the CPU a break...
Re: Giving the CPU a break...
- Subject: Re: Giving the CPU a break...
- From: Kevin Elliott <email@hidden>
- Date: Tue, 19 Nov 2002 09:33:00 -0800
NSThread's sleepUntilDate will do what you want to do. You could
also call the bsd call "sleep" directly. Type man 3 sleep for
details.
RE: how long to sleep. It very much depends on what your doing and
how fast you want to do it. I'd suggest you code it up and
experiment with values until you find a balance your happy with.
At 12:04 -0700 on 11/18/02, Buzz Andersen wrote:
This is probably a terribly obvious rookie question, but I'll ask it
any way. A program I am working on contains a very tight loop that
can often run through many thousands of iterations at a time. As
you might expect, this is having a tendency to really max out my CPU
usage and make my computer very unresponsive.
My question is: is there a good way for me to give the CPU a break
and make the computer more responsive during this loop without
compromising performance significantly? I have tried moving my
thread priority down to 0.1, but that doesn't seem to make a
difference. Would NSThread's sleepUntilDate: methods be what I'm
looking for? If so, how long do you think I would need to sleep to
really alleviate the problem without compromising performance too
much? Or, alternatively, is there a better way to accomplish what
I'm trying to do (this way seems a little hacky to me)?
--
_____________________________________________
Kevin Elliott <
mailto:email@hidden> ICQ#23758827
_______________________________________________
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.