[Expat-discuss] Expat lib and Pthreads

Nick MacDonald nickmacd at gmail.com
Sat Jan 15 17:18:20 CET 2011


Potentially, yes... depending on how you intend to keep the state of
the two threads separate.  You may want to learn about the value of
User Data, and set your thread state in some data structure, the
pointer of which you would pass into eXpat with XML_SetUserData such
that it can pass it along to the handler routines and you can use it
in the handlers to get access to your thread specific state.

XML_SetUserData(XML_Parser p, void *userData)
This sets the user data pointer that gets passed to handlers.

Good luck with your project...
  Nick


On Thu, Jan 13, 2011 at 6:09 PM, Mikhail Strizhov
<strizhov at netsec.colostate.edu> wrote:
> I have fully working parsing module and I need to use this module with two
> threads (C pthread library) to parse different xml documents simultaneously.
> Both threads will launch:
>
> XML_Parser parser = XML_ParserCreate(NULL);
> XML_SetElementHandler(parser, _start_hndl, _end_hndl);
> XML_SetCharacterDataHandler(parser,_char_hndl );
>
> Will I have inconsistency if both threads will use _start_hndl() and
> _end_hndl() handler functions?


More information about the Expat-discuss mailing list