Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / intrusive / thread_safety.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Thread safety guarantees</title>
6 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../intrusive.html" title="Chapter&#160;19.&#160;Boost.Intrusive">
10 <link rel="prev" href="value_traits.html" title="Containers with custom ValueTraits">
11 <link rel="next" href="boost_intrusive_iterators.html" title="Boost.Intrusive Iterator features">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
16 <td align="center"><a href="../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="value_traits.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="boost_intrusive_iterators.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="section">
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="intrusive.thread_safety"></a><a class="link" href="thread_safety.html" title="Thread safety guarantees">Thread safety guarantees</a>
29 </h2></div></div></div>
30 <p>
31       Intrusive containers have thread safety guarantees similar to STL containers.
32     </p>
33 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
34 <li class="listitem">
35           Several threads having read or write access to different instances is safe
36           as long as inserted objects are different.
37         </li>
38 <li class="listitem">
39           Concurrent read-only access to the same container is safe.
40         </li>
41 </ul></div>
42 <p>
43       Some Intrusive hooks (auto-unlink hooks, for example) modify containers without
44       having a reference to them: this is considered a write access to the container.
45     </p>
46 <p>
47       Other functions, like checking if an object is already inserted in a container
48       using the <code class="computeroutput"><span class="identifier">is_linked</span><span class="special">()</span></code>
49       member of safe hooks, constitute read access on the container without having
50       a reference to it, so no other thread should have write access (direct or indirect)
51       to that container.
52     </p>
53 <p>
54       Since the same object can be inserted in several containers at the same time
55       using different hooks, the thread safety of <span class="bold"><strong>Boost.Intrusive</strong></span>
56       is related to the containers and also to the object whose lifetime is manually
57       managed by the user.
58     </p>
59 <p>
60       As we can see, the analysis of the thread-safety of a program using <span class="bold"><strong>Boost.Intrusive</strong></span> is harder than with non-intrusive containers.
61     </p>
62 <p>
63       To analyze the thread safety, consider the following points:
64     </p>
65 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
66 <li class="listitem">
67           The auto-unlink hook's destructor and <code class="computeroutput"><span class="identifier">unlink</span><span class="special">()</span></code> functions modify the container indirectly.
68         </li>
69 <li class="listitem">
70           The safe mode and auto-unlink hooks' <code class="computeroutput"><span class="identifier">is_linked</span><span class="special">()</span></code> functions are a read access to the container.
71         </li>
72 <li class="listitem">
73           Inserting an object in containers that will be modified by different threads
74           has no thread safety guarantee, although in most platforms it will be thread-safe
75           without locking.
76         </li>
77 </ul></div>
78 </div>
79 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
80 <td align="left"></td>
81 <td align="right"><div class="copyright-footer">Copyright &#169; 2005 Olaf Krzikalla<br>Copyright &#169; 2006-2015 Ion Gaztanaga<p>
82         Distributed under the Boost Software License, Version 1.0. (See accompanying
83         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>)
84       </p>
85 </div></td>
86 </tr></table>
87 <hr>
88 <div class="spirit-nav">
89 <a accesskey="p" href="value_traits.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="boost_intrusive_iterators.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
90 </div>
91 </body>
92 </html>