1[/ 2 Copyright 2006-2007 John Maddock. 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE_1_0.txt or copy at 5 http://www.boost.org/LICENSE_1_0.txt). 6] 7 8 9[section:thread_safety Thread Safety] 10 11The Boost.Regex library is thread safe when Boost is: you can verify that 12Boost is in thread safe mode by checking to see if `BOOST_HAS_THREADS` is 13defined: this macro is set automatically by the config system when 14threading support is turned on in your compiler. 15 16Class [basic_regex] and its typedefs regex and wregex are thread safe, 17in that compiled regular expressions can safely be shared between threads. 18The matching algorithms [regex_match], [regex_search], and [regex_replace] 19are all re-entrant and thread safe. Class [match_results] is now thread safe, 20in that the results of a match can be safely copied from one thread to 21another (for example one thread may find matches and push [match_results] 22instances onto a queue, while another thread pops them off the other end), 23otherwise use a separate instance of [match_results] per thread. 24 25The [link boost_regex.ref.posix POSIX API functions] are all re-entrant and thread safe, regular 26expressions compiled with regcomp can also be shared between threads. 27 28The [link boost_regex.ref.deprecated.old_regex class RegEx] is 29only thread safe if each thread gets its own 30RegEx instance (apartment threading) - this is a consequence of 31RegEx handling both compiling and matching regular expressions. 32 33Finally note that changing the global locale invalidates all compiled 34regular expressions, therefore calling `set_locale` from one thread 35while another uses regular expressions will produce unpredictable results. 36 37There is also a requirement that there is only one thread executing prior 38to the start of main(). 39 40[endsect] 41 42