May 23, 2011
On Mon, 23 May 2011 03:49:49 +0300, Adam D. Ruppe <destructionator@gmail.com> wrote:

> What scared me was that the data comes in on a socket... so wouldn't
> that come with the same threading problems my simple http server
> has? (Where one slow request means everyone else has to wait)

Asynchronous networking is all the rage now. lighttpd is completely asynchronous and VERY fast.

Have you heard about NodeJS? It uses asynchronous IO as the primary (only?) way to do IO. As closures are first-class JavaScript language features, async IO works pretty well there. I dream about creating something like this in D as well one day.

Anyway, the idea is that nothing should block your event loop for more than a millisecond or so. If something takes longer, then either you need to look into "asynchronizing" it (file access?), or putting it in a separate, isolated thread.

-- 
Best regards,
 Vladimir                            mailto:vladimir@thecybershadow.net
May 23, 2011
Vladimir Panteleev wrote:
> Have you heard about NodeJS?

Yeah. It's actually not too much different than the way my network manager code works in D (which the embedded http server is made on) although their implementation is much better than mine - I just use select() in the event loop.

The key to using it is to always return from your function as soon as possible. It will then add to your buffer and call the function again as new stuff comes in.

It actually works quite well for it's simplicity. The problem with using it for the cgi apps is they aren't really written to work in that style.
1 2 3
Next ›   Last »