Is it safe to declare a static/global variable with a fixed boost::wregex and then use it from multiple threads without worrying about the regex's internal state (if Boost has been compiled with BOOST_HAS_THREADS)?
e.g.
boost::wregex g_regex( L"common|test" );
then have multiple threads calling:
if ( boost::regex_search( test_str, g_regex ) )
...
http://www.boost.org/doc/libs/1_51_0/libs/regex/doc/html/boost_regex/background_information/thread_safety.html
Class basic_regex and its typedefs regex and wregex are thread safe, in that compiled regular expressions can safely be shared between threads. The matching algorithms regex_match, regex_search, and regex_replace are all re-entrant and thread safe. Class match_results is now thread safe, in that the results of a match can be safely copied from one thread to another (for example one thread may find matches and push match_results instances onto a queue, while another thread pops them off the other end), otherwise use a separate instance of match_results per thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With