[Xapian-discuss] multi-threading?
Olly Betts
olly at survex.com
Tue May 3 17:48:08 BST 2005
On Tue, May 03, 2005 at 12:12:10PM -0400, Rita wrote:
> I have a quick question, does the xapian code supports
> multi-threading? Is the code thraed-safe?
http://xapian.org/docs/overview.html says:
Thread safety
There's no pthread specific code in Xapian. If you want to use the same
object concurrently from different threads, it's up to you to police
access (with a mutex or in some other way) to ensure only one method is
being executed at once. The reason for this is to avoid adding the
overhead of locking and unlocking mutexes when they aren't required. It
also makes the Xapian code easier to maintain, and simplifies building
it.
For most applications, this is unlikely to be an issue - generally the
calls to Xapian are likely to be from a single thread. And if they
aren't, you can just create an entirely separate Xapian::Database object
in each thread - this is no different to accessing the same database
from two different processes.
In 0.8.5, Xapian::QueryParser isn't thread safe (it uses bison which
forces use of static data). This will be fixed in 0.9.0 (to be released
this week, I hope). In 0.9.0 QueryParser has been reimplemented and no
longer uses bison.
Cheers,
Olly
More information about the Xapian-discuss
mailing list