Re: pthreads and CF runloops (possibly slightly OT)
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Nov 10, 2005, at 9:07 AM, Philip Lukidis wrote: When I create a pthread, is a new run loop created, and is the pthread associated with it? -Shawn _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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). 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> This email sent to site_archiver@lists.apple.com
participants (1)
-
Shawn Erickson