Re: Question on threads running in my Foundation tool
Re: Question on threads running in my Foundation tool
- Subject: Re: Question on threads running in my Foundation tool
- From: Shawn Erickson <email@hidden>
- Date: Sat, 21 Feb 2009 09:27:46 -0800
On Fri, Feb 20, 2009 at 6:50 PM, Michael Vannorsdel <email@hidden> wrote:
> It should be more like:
>
> //create timer
> //add timer to runloop
>
> CFRunLoopRun(); //code blocks here (not really since the loop is
> running) until runloop exits due to no longer having observers or timers
>
> //do thread cleanup and exit
Note framework code could add sources to the runloop outside of your
direct control. This can make depending on the runloop exiting when
you remove your sources problematic. I generally place an event source
in the runloop that I can trigger that causes the runloop to stop
(e.g. CFRunLoopStop(CFRunLoopGetCurrent());). This does two things: 1)
ensures that the runloop always has at least one source so it will
continue to run and 2) I can get it to exit without having to worry
about other sources being added outside of my control / knowledge.
Just understand by using a source to stop a runloop you are
essentially queueing such a request... which may or may not be what
you want.
-Shawn
_______________________________________________
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