Re: Pausing and terminating a thread
Re: Pausing and terminating a thread
- Subject: Re: Pausing and terminating a thread
- From: Doug Wyatt <email@hidden>
- Date: Tue, 30 Aug 2005 21:49:55 -0700
On Aug 30, 2005, at 15:18, Ben Haller wrote:
If your work loop is doing easy, fast stuff, you end up checking
the flag a *lot*, and it slows down your work significantly.
Unrolling your work loop can help somewhat, but of course you don't
want to do that too much or you'll start causing cache problems
because your code is too big, plus of course unrolled code is hard
to maintain. So it's an annoying problem.
You don't have to unroll ... an approach like this works and for all
but the most trivial work loops adds negligible overhead.
int iteration = 0;
while (.... doing some work ....) {
if (++iteration == 100) {
// update progress bar, check to see if you're done
iteration = 0;
}
}
--
Doug Wyatt
http://www.dougwyatt.net/ <-- music
http://www.sonosphere.com/Doug/ <-- etc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden