How to ensure thread-safety

Kim Walisch kim.walisch at gmail.com
Thu Feb 8 15:18:12 GMT 2018


Hi,

I have read the concurrency webpage from the Xapian documentation:

http://getting-started-with-xapian.readthedocs.io/en/latest/concepts/concurrency.html

But it is still not clear to me how to ensure thread-safety when using
libxapian (C++ API). Usually when doing multi-threading many threads can
read the same variable concurrently without locking provided none of the
threads modifies the variable.

1) Does this apply for Xapian as well? I.e. Can many thread search the
database provided each thread uses their own Xapian database object and
none of the threads updates/indexes the database?

2) What about when one thread indexes a new document? Do I need to
ensure (by locking) that no other thread reads or write the database until
the first thread has finished indexing?

Thanks,
Kim


More information about the Xapian-discuss mailing list