FROM : ben syverson
DATE : Fri May 16 00:28:13 2008
On May 15, 2008, at 4:17 PM, Jens Alfke wrote:
> You can wire up kqueues to a runloop fairly easily. Instead of
> blocking, the kqueue will post an event to the runloop when
> something happens. Then instead of waiting in kevent, you just
> handle events in your runloop, and your callback will be invoked as
> necessary.
That's interesting... Although I think for now, having kevent in a
separate thread is working okay. When it gets a request, it locks a
shared NSMutableArray queue and sets an NSConditionLock indicating
that a worker thread should copy and clear the queue and then process
the requests... It seems to be working very well.
> (My advice: unless you're seriously trying to write The Fastest Web
> Server In The World, use NSStream and/or CFNetwork and follow their
> asynchronous/runloop model.)
It's not that I'm trying to write The Fastest Web Server In The World,
it's just that I'm trying to squeeze every dollar out of my server
hardware. Besides, if I'm writing something from scratch, why not make
it scream? :)
- ben
DATE : Fri May 16 00:28:13 2008
On May 15, 2008, at 4:17 PM, Jens Alfke wrote:
> You can wire up kqueues to a runloop fairly easily. Instead of
> blocking, the kqueue will post an event to the runloop when
> something happens. Then instead of waiting in kevent, you just
> handle events in your runloop, and your callback will be invoked as
> necessary.
That's interesting... Although I think for now, having kevent in a
separate thread is working okay. When it gets a request, it locks a
shared NSMutableArray queue and sets an NSConditionLock indicating
that a worker thread should copy and clear the queue and then process
the requests... It seems to be working very well.
> (My advice: unless you're seriously trying to write The Fastest Web
> Server In The World, use NSStream and/or CFNetwork and follow their
> asynchronous/runloop model.)
It's not that I'm trying to write The Fastest Web Server In The World,
it's just that I'm trying to squeeze every dollar out of my server
hardware. Besides, if I'm writing something from scratch, why not make
it scream? :)
- ben






Cocoa mail archive

