Re: NSRunLoop / CFRunLoop
Re: NSRunLoop / CFRunLoop
- Subject: Re: NSRunLoop / CFRunLoop
- From: Alexander Cohen <email@hidden>
- Date: Fri, 13 Feb 2009 20:38:09 -0500
Le 13 févr. 09 à 21:54, Alexander Cohen a écrit :
Hi,
Not sure if this is the right place to ask since my question is
about CFRunLoop, not Cocoa but CoreFoundation. If not, please
direct me to the right list.
I'm looking for a way to get the main CFRunLoop on tiger. On
leopard, there is a simple call for it but i'm stuck with tiger for
now. And while i'm at it, i'd like to do something like [obj
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.
I'm sure it's possible but i'm not sure where to start.
thx
To get the main runloop, you can save it in a global variable at
program startup, and return it when requested.
There is no easy way to mimic performSelectorOnMainThread: as there
is no easy way to serialize a function call (unlike in Cocoa where
you can easily serialize a method call using NSInvocation to send it
on the main thread).
To do inter-thread messaging using only low-level frameworks, you
are stuck with the traditional facilities (socket, pipes, etc.)
Just by curiosity, what prevent you to use the Foundation framework ?
I'm in some C++ code and cannot use Foundation, only CF. I did find a
solution though. The solution is to create a RunLoopSource and pass it
an object ( C++ ) that knows what function to call in it's context.
When the source is signaled, i'm in the main thread ( cause i added it
to the main thread's RunLoop ), works like a charm. Is this something
that is good or am I doing this all wonrg? :)
thx
AC_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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