Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / regex / doc / html / boost_regex / background / thread_safety.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Thread Safety</title>
5 <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Boost.Regex 5.1.4">
8 <link rel="up" href="../background.html" title="Background Information">
9 <link rel="prev" href="locale.html" title="Localization">
10 <link rel="next" href="examples.html" title="Test and Example Programs">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="locale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../background.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="boost_regex.background.thread_safety"></a><a class="link" href="thread_safety.html" title="Thread Safety">Thread Safety</a>
28 </h3></div></div></div>
29 <p>
30         The Boost.Regex library is thread safe when Boost is: you can verify that
31         Boost is in thread safe mode by checking to see if <code class="computeroutput"><span class="identifier">BOOST_HAS_THREADS</span></code>
32         is defined: this macro is set automatically by the config system when threading
33         support is turned on in your compiler.
34       </p>
35 <p>
36         Class <a class="link" href="../ref/basic_regex.html" title="basic_regex"><code class="computeroutput"><span class="identifier">basic_regex</span></code></a>
37         and its typedefs regex and wregex are thread safe, in that compiled regular
38         expressions can safely be shared between threads. The matching algorithms
39         <a class="link" href="../ref/regex_match.html" title="regex_match"><code class="computeroutput"><span class="identifier">regex_match</span></code></a>,
40         <a class="link" href="../ref/regex_search.html" title="regex_search"><code class="computeroutput"><span class="identifier">regex_search</span></code></a>,
41         and <a class="link" href="../ref/regex_replace.html" title="regex_replace"><code class="computeroutput"><span class="identifier">regex_replace</span></code></a>
42         are all re-entrant and thread safe. Class <a class="link" href="../ref/match_results.html" title="match_results"><code class="computeroutput"><span class="identifier">match_results</span></code></a> is now thread safe,
43         in that the results of a match can be safely copied from one thread to another
44         (for example one thread may find matches and push <a class="link" href="../ref/match_results.html" title="match_results"><code class="computeroutput"><span class="identifier">match_results</span></code></a> instances onto a queue,
45         while another thread pops them off the other end), otherwise use a separate
46         instance of <a class="link" href="../ref/match_results.html" title="match_results"><code class="computeroutput"><span class="identifier">match_results</span></code></a>
47         per thread.
48       </p>
49 <p>
50         The <a class="link" href="../ref/posix.html" title="POSIX Compatible C API's">POSIX API functions</a> are
51         all re-entrant and thread safe, regular expressions compiled with regcomp
52         can also be shared between threads.
53       </p>
54 <p>
55         The <a class="link" href="../ref/deprecated/old_regex.html" title="High Level Class RegEx (Deprecated)">class RegEx</a>
56         is only thread safe if each thread gets its own RegEx instance (apartment
57         threading) - this is a consequence of RegEx handling both compiling and matching
58         regular expressions.
59       </p>
60 <p>
61         Finally note that changing the global locale invalidates all compiled regular
62         expressions, therefore calling <code class="computeroutput"><span class="identifier">set_locale</span></code>
63         from one thread while another uses regular expressions will produce unpredictable
64         results.
65       </p>
66 <p>
67         There is also a requirement that there is only one thread executing prior
68         to the start of main().
69       </p>
70 </div>
71 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
72 <td align="left"></td>
73 <td align="right"><div class="copyright-footer">Copyright &#169; 1998-2013 John Maddock<p>
74         Distributed under the Boost Software License, Version 1.0. (See accompanying
75         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
76       </p>
77 </div></td>
78 </tr></table>
79 <hr>
80 <div class="spirit-nav">
81 <a accesskey="p" href="locale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../background.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
82 </div>
83 </body>
84 </html>