Re: thread spinning ...
Re: thread spinning ...
- Subject: Re: thread spinning ...
- From: Chris Suter <email@hidden>
- Date: Wed, 6 Dec 2006 15:28:01 +1100
I believe runMode:beforeDate can return immediately when there are no
input sources.
I'll bet it's returning NO.
- Chris
On 06/12/2006, at 3:21 PM, Martin Redington wrote:
Please remind me never to do any multi-threaded programming again.
I have a loop that drives my worker thread, that looks something
like the code below. Recently, I've observed one of these threads
(occasionally more, but usually just one), "spinning" in this loop,
and consuming a lot of CPU. I'm pretty certain that at the time,
the thread is not receiving any messages, just waiting around to be
reaped. Normally, this code runs without incident.
// threadRunning is a utility method that checks the
threadDictionary to see if a flag has been set.
// it is only set or accessed from within the current thread.
while ([self threadRunning])
{
NSDate *newDate = [[NSDate alloc] initWithTimeIntervalSinceNow:
0.50];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:newDate];
[newDate release];
}
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden