FROM : Hamish Allan
DATE : Fri May 16 00:33:07 2008
On Thu, May 15, 2008 at 8:16 PM, ben syverson <<email_removed>> 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_removed>> 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
DATE : Fri May 16 00:33:07 2008
On Thu, May 15, 2008 at 8:16 PM, ben syverson <<email_removed>> 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_removed>> 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 mail archive

