|
Boost Users : |
From: João Abecasis (jpabecasis_at_[hidden])
Date: 2006-04-13 19:37:47
Hi!
Tim Blechmann wrote:
> i'm currently looking into the spirit library to create a parser ... it
> seems to be threadsafe, but it's using thread locks.
> is it possible to use the library in a lockfree manner? can i be sure,
> that there will be no lock misses, when i'm not sharing parsers between
> the threads?
Regarding Spirit, it has two different thread-related modes of
operation. The default one is thread-unsafe because of static data used
internally by Spirit. If you use Spirit from a single thread at a time
you'll be safe even in a multithreaded environment, however.
The thread-safe mode is triggered by defining BOOST_SPIRIT_THREADSAFE.
When this is defined, mutexes (and other Boost.Threads utilities) are
used to ensure thread-safe initialization and sharing of static data
across threads.
If you're NOT sharing parsers across threads or if you DO manage locking
yourself you can skip the definition of BOOST_SPIRIT_THREADSAFE.
If you (or anyone else, for that matter) will be trying
BOOST_SPIRIT_THREADSAFE be sure to try the patch I posted here,
http://article.gmane.org/gmane.comp.parsers.spirit.general/10472
and report any bugs you come across ;-)
Best regards,
João
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net