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

Re: HTText callback functions for multiple HTRequests

From: Vic Bancroft <bancroft@america.net>
Date: Sat, 12 Apr 2008 01:56:35 -0400
Message-ID: <48004F13.1000209@america.net>
To: New Developer <developer.new@gmail.com>
CC: www-lib@w3.org

New Developer wrote:
> I'm just starting to use libwww and had a question regarding multiple
> requests. I am using libwww to parse data from websites and fill up my
> internal data structures. I checked the sample codes that are up and
> specifically I am using the techniques used in showtag.c and showtext.c.
Welcome, that is a good place to start . . .
> What I a doing right now is registering the callback functions
> beginElement(), endElement() and addText() with:
> HText_registerElementCallback(beginElement, endElement);
> HText_registerTextCallback(addText)
> This achieves what I am trying to do. However, these callback functions are
> not tied to a particular HTequest. What if I want to issue two separate
> HTRequests (to different URLs, of course) and want two different sets of
> callback functions to be called once the data start coming back?
As has been discussed in the archives, the libwww is not designed to be 
multithreaded.  Rather the design is to achieve high throughput with a 
flexible architecture . . .
> Is there any way to tie the HTText_register*() functions with specific
> requests? Or do I have to use the HTStream class to achieve what I am trying
> to do? In case I have to use HTStream class, I'd really appreciate if
> someone can give some high level pointers on how to get started.
Sure, you might consider constructing a thread safe queue, perhaps using 
a struct which includes the head and tail pointer of an HTList.  Each 
queue entry could be a container of your request specific call back 
function pointers . . .


"The future is here. It's just not evenly distributed yet."
 -- William Gibson, quoted by Whitfield Diffie
Received on Saturday, 12 April 2008 17:30:13 UTC

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