W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

Re: the theory and reality of threads and async in user agents

From: <jose.kahan@w3.org>
Date: Thu, 10 Jun 1999 17:24:45 +0200 (MET DST)
Message-Id: <199906101524.RAA07953@tuvalu.inrialpes.fr>
To: mda@discerning.com (Mark D. Anderson)
Cc: www-lib@w3.org
Hello Mark,

I can confirm you that in the Amaya interface to libwww, we only
use async sockets. Under Unix, we use a single thread throughout.
Under Windows, we have two threads, one specifically for socket events,
and the other for the user-interface. Nevertheless, the socket interface 
uses async sockets too.

More specifically, when we create a new socket, we associate some context
with the socket which basically stores state information and the name of
a handler (an automate in fact), and which also tells which HTTP request is 
associated with the socket. All network calls are made in non-blocking mode.
After we finished doing some processing, we enter an event loop. In this
loop we have a select() function, which returns the socket identitifers 
where there has been some activity. Then we go thru each socket, retrieve 
the context and deal with it. When all sockets have been dealed to, the event
loop continues. Under Unix, the same event loop is used to handle user
interface events.

Other libwww context and state automata allow to deal with pipelining, 
keep-alive connections and so on.

I think that our only blocking net call is the DNS server lookup (system

libwww already proposes an event loop. It's found in the HTEvtLst.c file and
all the sample libwww appplications use it. In Amaya, we use an event loop
outside of libwww (using Xt), but still use the same callback mechanism when
dealing with sockets.

I hope this answers your question regarding Amaya.

If useful (although you seem to know this stuff well), you can find a
better explanation of async/blocking requests in Stevens' "Unix Network 
Programming book", Vol 1, 2nd Ed.

In our previous episode, Mark D. Anderson said:
> -----------------
> I used a threaded debug utility to trace Netscape on Windows

Just for curiosity, what's the name of that tool?  :)


Received on Thursday, 10 June 1999 11:24:52 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:49 UTC