Re: Where to send different messages while RunLoop is running
Re: Where to send different messages while RunLoop is running
- Subject: Re: Where to send different messages while RunLoop is running
- From: Alastair Houghton <email@hidden>
- Date: Mon, 12 Oct 2009 09:15:55 +0100
On 11 Oct 2009, at 21:45, John Love wrote:
I definitely do agree that polling is sporadic or unpredictable --
and taking your clue about +distantFuture to heart, I changed it to
+date to indicate now, or immediately -- and it now works even with -
shouldExit sending other message IDs. I just need to think where to
send these other message IDs per your recommendation.
It isn't just that, as I said, polling wastes CPU time and power too.
Without knowing *what* you're polling for, it's difficult to suggest
an alternative, however.
I don't think I'd use +date (i.e. immediate return), though, since it
seems unlikely that you need to poll that fast. Unless whatever
you're polling blocks, that'll result in a busy wait, which is a
really bad idea. For things that the user wants to see "immediately",
I think I'd be inclined to poll at 0.1s or even 0.25s intervals, as
that's going to be more than quick enough in practice.
Another alternative that you might consider is writing your own run
loop source to trigger the run loop in your main thread. That would
avoid using the NSMachPort altogether, and you probably wouldn't need
a run loop in your secondary thread (just a loop with a sleep() in it
if you absolutely *must* poll something).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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