W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2003

Re: how pipeline works

From: Richard Atterer <richard@list03.atterer.net>
Date: Mon, 8 Sep 2003 23:27:32 +0200
To: www-lib@w3.org
Message-ID: <20030908212732.GA2066@nenya.lan>

On Mon, Sep 08, 2003 at 10:15:33AM -0700, Jerry G. Chiuan wrote:
> I might need to correct my guess in previous email here
> On client side, since the thread has to wait for the response after the
> request is sent out "correspondingly", it is impossible to have
> one dedicated thread taking care of sending requests and one for receiving
> responses ( but we can do it in Socket implementation )

I'd say it is possible to have one thread which sends requests and one
which receives the answers, if the socket that both threads access isn't
locked completely during the time any thread is blocked.

(This is a general remark; _libwww_ doesn't use threads, it avoids blocking
calls by using select().)

> I might need to implement a thread pool, to pull out one thread for one
> request....therefore there is a maximun number of requests which is
> possibly sent out without waiting for their responses.
> 
> Is it a correct thought?

It depends very much on how your whole application is organized.

My own libwww-using code is single-threaded. It starts new requests from
the "main event loop" which is called at regular intervals, so it can still
take full advantage of pipelining.

Since libwww is not thread safe, any solution of yours in which several 
threads access libwww would simply have one "libwww thread" which gets 
handed the requests from the other threads and passes them to libwww.

I must say I'm not really sure what you have in mind. :)

Maybe you're thinking in terms of the example libwww programs which all
have code which first sends the request, then calls some other libwww
functions and blocks until they return the data.

This is not how you should use libwww once your program has >1 concurrent 
requests running. You can't run in parallel several threads which do this 
- libwww will crash!

The docs in /Library/User/Architecture/Events.html explain the basic idea
of a central event loop. Unfortunately, this area of libwww is a rather
hard to understand, especially if the concept of an event loop is new to
you.

I develop a GTK+ app and was lucky enough to find the "glibwww" code which
plugs libwww into the GTK+ (more accurately glib) event loop. After a quick
look I think the eventloop.c example shows how to do >1 requests without
glib.

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/|  http://atterer.net  |  0x888354F7
   '` 
Received on Monday, 8 September 2003 17:30:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:43 GMT