]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/doc/thread_safety.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / regex / doc / thread_safety.qbk
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
11 The Boost.Regex library is thread safe when Boost is: you can verify that
12 Boost is in thread safe mode by checking to see if `BOOST_HAS_THREADS` is
13 defined: this macro is set automatically by the config system when
14 threading support is turned on in your compiler.
15
16 Class [basic_regex] and its typedefs regex and wregex are thread safe,
17 in that compiled regular expressions can safely be shared between threads.
18 The matching algorithms [regex_match], [regex_search], and [regex_replace]
19 are all re-entrant and thread safe. Class [match_results] is now thread safe,
20 in that the results of a match can be safely copied from one thread to
21 another (for example one thread may find matches and push [match_results]
22 instances onto a queue, while another thread pops them off the other end),
23 otherwise use a separate instance of [match_results] per thread.
24
25 The [link boost_regex.ref.posix POSIX API functions] are all re-entrant and thread safe, regular
26 expressions compiled with regcomp can also be shared between threads.
27
28 The [link boost_regex.ref.deprecated_interfaces.old_regex class RegEx] is
29 only thread safe if each thread gets its own
30 RegEx instance (apartment threading) - this is a consequence of
31 RegEx handling both compiling and matching regular expressions.
32
33 Finally note that changing the global locale invalidates all compiled
34 regular expressions, therefore calling `set_locale` from one thread
35 while another uses regular expressions will produce unpredictable results.
36
37 There is also a requirement that there is only one thread executing prior
38 to the start of main().
39
40 [endsect]
41