[spirit] thread safety / lock freedom

hi all, 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? thanks in advance ... tim -- TimBlechmann@gmx.de ICQ: 96771783 http://www.mokabar.tk All we composers really have to work with is time and sound - and sometimes I'm not even sure about sound. Morton Feldman

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
participants (2)
-
João Abecasis
-
Tim Blechmann