Re: Re: Yielding an NSThread-started thread
Re: Re: Yielding an NSThread-started thread
- Subject: Re: Re: Yielding an NSThread-started thread
- From: "Philip Q" <email@hidden>
- Date: Wed, 22 Nov 2006 13:27:56 +1300
On 22/11/06, Alastair Houghton <email@hidden> wrote:
If you read the documentation, you'll see that NSThread is layered on
top of POSIX threads, so you can safely call pthread_yield().
Oops, I seem to have missed that sentence.
Generally speaking, however, you wouldn't want to do that; it's much
better to signal a thread explicitly using a condition variable, a
mutex or some other kind of synchronisable object. Is there some
reason that you can't do that in your case?
In this case, I'm signalling a thread to exit, but while it wraps the
other thread has nothing to do but wait for it, so instead of
continually polling the condition variable it might as well yield
after each check to give the other thread the chance to do something.
-Phil
_______________________________________________
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