Re: Using NSThreads in command-line apps
Re: Using NSThreads in command-line apps
- Subject: Re: Using NSThreads in command-line apps
- From: "Hamish Allan" <email@hidden>
- Date: Thu, 15 May 2008 23:33:07 +0100
On Thu, May 15, 2008 at 8:16 PM, ben syverson <email@hidden> wrote:
> I don't want to listen to any input, and I want the loop to execute as fast
> as possible. However, NSRunLoop says I need to set a timer or an input...
On Thu, May 15, 2008 at 8:53 PM, ben syverson <email@hidden> wrote:
> I have one thread which runs the server's infinite loop. It can't be the
> main thread, because it calls kevent, which doesn't return a value until
> there's an event. So that thread's loop stops while kevent is waiting.
The event you're using kqueue to block for is the input to which
NSRunLoop refers.
NSRunLoop is just Cocoa's implementation of a kevent()-style loop.
Instead of adding your socket to the kqueue, add it to the run loop
instead. (See e.g. http://cocoadevcentral.com/articles/000039.php --
which uses the CFRunLoop interface, but it's the same run loop.) No
need for a separate thread to handle the main task.
Hamish
_______________________________________________
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