Re: Yielding an NSThread-started thread
Re: Yielding an NSThread-started thread
- Subject: Re: Yielding an NSThread-started thread
- From: Alastair Houghton <email@hidden>
- Date: Tue, 21 Nov 2006 14:12:26 +0000
On 21 Nov 2006, at 13:11, Philip Q wrote:
Is there a recommended/good way to yield a thread started using
NSThread while it waits for another?
pthread has pthread_yield(), libc has sched_yield(), Thread Manager
has YieldToAnyThread(), Multiprocessing Services has MPYield() -- but
I don't see a Cocoa one, and I don't know what the unexpected
consequences might be of calling one from another library?
If you read the documentation, you'll see that NSThread is layered on
top of POSIX threads, so you can safely call pthread_yield().
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?
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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