Re: Inserting a task into the run loop
Re: Inserting a task into the run loop
- Subject: Re: Inserting a task into the run loop
- From: Graham Cox <email@hidden>
- Date: Mon, 23 Mar 2015 09:23:57 +1100
> On 22 Mar 2015, at 4:21 pm, Kyle Sluder <email@hidden> wrote:
>
> Use a run loop observer?
OK, that looks relevant. I didn't see the term in NSRunLoop so....
But looking at the docs, I wonder if this is really what I want. If nothing is going on, won't my run loop simply go to sleep? That means I'm only going to get called once per run loop if there are other events happening. On reflection, I don't think that's going to work for me here. I need my code to run all the time. It's not heavyweight processing, so it isn't going to be a huge drain on anything, but it does need to have frequent calls. My timer approach does keep the run loop awake, but it feels a bit off to be using a timer for something that isn't truly a time-related task, only a task that needs to run "as often as possible".
My code can also run as a separate thread, and when it does so, it's just an endless loop. That's fine, except that at a higher level it's driving or updating a UI, so it has to go to a lot of trouble to ensure all those updates are pushed onto the main thread. In practice it's just easier to run all the code on the main thread synchronously.
--Graham
_______________________________________________
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