Skip navigation.
 
mlRe: Using NSThreads in command-line apps
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

Related mailsAuthorDate
mlUsing NSThreads in command-line apps ben syverson May 15, 20:42
mlRe: Using NSThreads in command-line apps Bill Bumgarner May 15, 20:47
mlRe: Using NSThreads in command-line apps Randall Meadows May 15, 20:49
mlRe: Using NSThreads in command-line apps Uli Kusterer May 15, 20:51
mlRe: Using NSThreads in command-line apps Jens Alfke May 15, 20:52
mlRe: Using NSThreads in command-line apps ben syverson May 15, 21:16
mlRe: Using NSThreads in command-line apps ben syverson May 15, 21:17
mlRe: Using NSThreads in command-line apps Bill Bumgarner May 15, 21:25
mlRe: Using NSThreads in command-line apps Bill Bumgarner May 15, 21:31
mlRe: Using NSThreads in command-line apps ben syverson May 15, 21:53
mlRe: Using NSThreads in command-line apps Jens Alfke May 15, 23:17
mlRe: Using NSThreads in command-line apps ben syverson May 16, 00:28
mlRe: Using NSThreads in command-line apps Sherm Pendley May 16, 00:31
mlRe: Using NSThreads in command-line apps Hamish Allan May 16, 00:33
mlRe: Using NSThreads in command-line apps ben syverson May 16, 00:40
mlRe: Using NSThreads in command-line apps Hamish Allan May 16, 01:06
mlRe: Using NSThreads in command-line apps Jens Alfke May 16, 03:02
mlRe: Using NSThreads in command-line apps ben syverson May 16, 06:50