Re: [xml] Thread safe
- From: Daniel Veillard <veillard redhat com>
- To: Xiang Yan <xyan primustel ca>
- Cc: xml gnome org
- Subject: Re: [xml] Thread safe
- Date: Mon, 14 Apr 2003 10:56:14 -0400
On Mon, Apr 14, 2003 at 10:16:54AM -0400, Xiang Yan wrote:
Hi,
I have two questions for using libxml2 in a threading environment. The code is written in c++,
glibc2.96,pthread..:
1. for a "read-only" xmlDoc object(a xmlDocPtr), is it necessary to set up a mutex for reading?
not needed, concurrent reading will be fine.
2. there are two classes dealing with two different xmlDocPtr objects, one is a static xmlDocPtr for global
sharing, another is a per thread based xmlDoc content, I'm assuming I just need call
xmlInitParser()/xmlCleanupParser() once somewhere globally, is this right?
xmlInitParser/xmlCleanupParser are really library wide calls. Calling the
first explicitely as an initialization step is more safe when working
with threaded code. xmlCleanupParser() is only needed if you want to recollect
the few kilobytes of predefined data kept by the library once you know
you won't use that library anymore, in doubt simply don't call it at all.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]