File: thread_safety.qbk

package info (click to toggle)
boost1.62 1.62.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 686,420 kB
  • sloc: cpp: 2,609,004; xml: 972,558; ansic: 53,674; python: 32,437; sh: 8,829; asm: 3,071; cs: 2,121; makefile: 964; perl: 859; yacc: 472; php: 132; ruby: 94; f90: 55; sql: 13; csh: 6
file content (41 lines) | stat: -rw-r--r-- 1,848 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[/ 
  Copyright 2006-2007 John Maddock.
  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
]


[section:thread_safety Thread Safety]

The Boost.Regex library is thread safe when Boost is: you can verify that 
Boost is in thread safe mode by checking to see if `BOOST_HAS_THREADS` is 
defined: this macro is set automatically by the config system when 
threading support is turned on in your compiler.

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.

The [link boost_regex.ref.posix POSIX API functions] are all re-entrant and thread safe, regular 
expressions compiled with regcomp can also be shared between threads.

The [link boost_regex.ref.deprecated_interfaces.old_regex class RegEx] is 
only thread safe if each thread gets its own 
RegEx instance (apartment threading) - this is a consequence of 
RegEx handling both compiling and matching regular expressions.

Finally note that changing the global locale invalidates all compiled 
regular expressions, therefore calling `set_locale` from one thread 
while another uses regular expressions will produce unpredictable results.

There is also a requirement that there is only one thread executing prior 
to the start of main().
     
[endsect]