Re: pthreads and CF runloops (possibly slightly OT)
Re: pthreads and CF runloops (possibly slightly OT)
- Subject: Re: pthreads and CF runloops (possibly slightly OT)
- From: Shawn Erickson <email@hidden>
- Date: Thu, 10 Nov 2005 09:34:32 -0800
On Nov 10, 2005, at 9:07 AM, Philip Lukidis wrote:
Is this true?
To be honest I am not sure I understand that statement in the
developer documentation... It may make sense to file a doc defect to
get that statement better clarified, it is a little lose in
terminology (I assume "your application's run loop" means your
applications main thread's runloop).
When I create a pthread, is a new run loop created, and is
the pthread associated with it?
Likely no because I believe they are created lazily but that is an
implementation detail (one that I am guessing at myself).
I ask this because I've done a simple (naive) test of outputting
the address of my main runloop, and then
outputting the address of a pthread runloop, and they are different.
They should be different since they are different threads. Each
thread can get its own runloop which is basically a thread local data
structure.
I've also modified my simple daemon to receive client messages in
the created
pthread, which seems to work.
Can you better explain how you did this so we can help make sure we
(and you) understand things? I ask given the following question.
So the question is, are pthreads associated with a runloop, and, if
not, how
can I create a runloop and associate a pthread with it?
In this case when running under your pthread simply use
CFRunLoopGetCurrent() but if in Cocoa/Carbon use their API for
runloops. Of course that only gets you a valid reference for the
runloop associated with the current thread (possibly "creating" it if
needed). To actually have the runloop do what it does you need to run
it.
<http://developer.apple.com/documentation/CoreFoundation/Conceptual/
CFRunLoops/Tasks/Running.html>
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden