2007-06-08 09:23:23 +00:00
< html >
< head >
2020-10-12 18:22:57 +01:00
< meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" >
2007-12-14 10:11:21 +00:00
< title > Thread Safety< / title >
2010-07-08 22:49:58 +00:00
< link rel = "stylesheet" href = "../../../../../../doc/src/boostbook.css" type = "text/css" >
2019-10-26 10:51:25 +01:00
< meta name = "generator" content = "DocBook XSL Stylesheets V1.79.1" >
2022-03-08 11:26:11 +00:00
< link rel = "home" href = "../../index.html" title = "Boost.Regex 7.0.1" >
2017-08-01 18:01:46 +01:00
< link rel = "up" href = "../background.html" title = "Background Information" >
2007-12-14 10:11:21 +00:00
< link rel = "prev" href = "locale.html" title = "Localization" >
< link rel = "next" href = "examples.html" title = "Test and Example Programs" >
2024-03-23 19:03:45 +00:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" >
2007-06-08 09:23:23 +00:00
< / head >
< body bgcolor = "white" text = "black" link = "#0000FF" vlink = "#840084" alink = "#0000FF" >
2007-08-13 17:54:01 +00:00
< table cellpadding = "2" width = "100%" > < tr >
2007-06-08 09:23:23 +00:00
< td valign = "top" > < img alt = "Boost C++ Libraries" width = "277" height = "86" src = "../../../../../../boost.png" > < / td >
2008-04-11 08:53:54 +00:00
< td align = "center" > < a href = "../../../../../../index.html" > Home< / a > < / td >
2007-06-08 09:23:23 +00:00
< td align = "center" > < a href = "../../../../../../libs/libraries.htm" > Libraries< / a > < / td >
2008-07-25 09:28:01 +00:00
< td align = "center" > < a href = "http://www.boost.org/users/people.html" > People< / a > < / td >
< td align = "center" > < a href = "http://www.boost.org/users/faq.html" > FAQ< / a > < / td >
2007-06-08 09:23:23 +00:00
< td align = "center" > < a href = "../../../../../../more/index.htm" > More< / a > < / td >
2007-08-13 17:54:01 +00:00
< / tr > < / table >
2007-06-08 09:23:23 +00:00
< hr >
< div class = "spirit-nav" >
2017-08-01 18:01:46 +01:00
< 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 >
2007-06-08 09:23:23 +00:00
< / div >
2013-12-14 17:42:13 +00:00
< div class = "section" >
2007-06-08 09:23:23 +00:00
< div class = "titlepage" > < div > < div > < h3 class = "title" >
2017-08-01 18:01:46 +01:00
< a name = "boost_regex.background.thread_safety" > < / a > < a class = "link" href = "thread_safety.html" title = "Thread Safety" > Thread Safety< / a >
2007-12-14 10:11:21 +00:00
< / h3 > < / div > < / div > < / div >
2007-06-08 09:23:23 +00:00
< p >
The Boost.Regex library is thread safe when Boost is: you can verify that
2007-12-14 10:11:21 +00:00
Boost is in thread safe mode by checking to see if < code class = "computeroutput" > < span class = "identifier" > BOOST_HAS_THREADS< / span > < / code >
2007-06-08 09:23:23 +00:00
is defined: this macro is set automatically by the config system when threading
support is turned on in your compiler.
< / p >
< p >
2008-12-23 11:46:00 +00:00
Class < a class = "link" href = "../ref/basic_regex.html" title = "basic_regex" > < code class = "computeroutput" > < span class = "identifier" > basic_regex< / span > < / code > < / a >
2007-06-08 09:23:23 +00:00
and its typedefs regex and wregex are thread safe, in that compiled regular
expressions can safely be shared between threads. The matching algorithms
2008-12-23 11:46:00 +00:00
< a class = "link" href = "../ref/regex_match.html" title = "regex_match" > < code class = "computeroutput" > < span class = "identifier" > regex_match< / span > < / code > < / a > ,
< a class = "link" href = "../ref/regex_search.html" title = "regex_search" > < code class = "computeroutput" > < span class = "identifier" > regex_search< / span > < / code > < / a > ,
and < a class = "link" href = "../ref/regex_replace.html" title = "regex_replace" > < code class = "computeroutput" > < span class = "identifier" > regex_replace< / span > < / code > < / a >
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,
2007-06-08 09:23:23 +00:00
in that the results of a match can be safely copied from one thread to another
2008-12-23 11:46:00 +00:00
(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,
2007-06-08 09:23:23 +00:00
while another thread pops them off the other end), otherwise use a separate
2008-12-23 11:46:00 +00:00
instance of < a class = "link" href = "../ref/match_results.html" title = "match_results" > < code class = "computeroutput" > < span class = "identifier" > match_results< / span > < / code > < / a >
2007-06-08 09:23:23 +00:00
per thread.
< / p >
< p >
2008-12-23 11:46:00 +00:00
The < a class = "link" href = "../ref/posix.html" title = "POSIX Compatible C API's" > POSIX API functions< / a > are
2007-06-08 09:23:23 +00:00
all re-entrant and thread safe, regular expressions compiled with regcomp
can also be shared between threads.
< / p >
< p >
Finally note that changing the global locale invalidates all compiled regular
2007-12-14 10:11:21 +00:00
expressions, therefore calling < code class = "computeroutput" > < span class = "identifier" > set_locale< / span > < / code >
2007-06-08 09:23:23 +00:00
from one thread while another uses regular expressions will produce unpredictable
results.
< / p >
< p >
There is also a requirement that there is only one thread executing prior
to the start of main().
< / p >
< / div >
2024-03-23 19:03:45 +00:00
< div class = "copyright-footer" > Copyright © 1998-2013 John Maddock< p >
2007-11-07 03:23:31 +00:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
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 > )
2007-12-14 10:11:21 +00:00
< / p >
2024-03-23 19:03:45 +00:00
< / div >
2007-06-08 09:23:23 +00:00
< hr >
< div class = "spirit-nav" >
2017-08-01 18:01:46 +01:00
< 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 >
2007-06-08 09:23:23 +00:00
< / div >
< / body >
< / html >