1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Limitations</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="../atomic.html" title="Chapter 7. Boost.Atomic">
10 <link rel="prev" href="usage_examples.html" title="Usage examples">
11 <link rel="next" href="porting.html" title="Porting">
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>
23 <div class="spirit-nav">
24 <a accesskey="p" href="usage_examples.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../atomic.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="porting.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="atomic.limitations"></a><a class="link" href="limitations.html" title="Limitations">Limitations</a>
29 </h2></div></div></div>
31 While <span class="bold"><strong>Boost.Atomic</strong></span> strives to implement the
32 atomic operations from C++11 as faithfully as possible, there are a few limitations
33 that cannot be lifted without compiler support:
35 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
37 <span class="bold"><strong>Using non-POD-classes as template parameter to <code class="computeroutput"><span class="identifier">atomic</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
38 results in undefined behavior</strong></span>: This means that any class containing
39 a constructor, destructor, virtual methods or access control specifications
40 is not a valid argument in C++98. C++11 relaxes this slightly by allowing
41 "trivial" classes containing only empty constructors. <span class="bold"><strong>Advise</strong></span>: Use only POD types.
44 <span class="bold"><strong>C++98 compilers may transform computation- to control-dependency</strong></span>:
45 Crucially, <code class="computeroutput"><span class="identifier">memory_order_consume</span></code>
46 only affects computationally-dependent operations, but in general there
47 is nothing preventing a compiler from transforming a computation dependency
48 into a control dependency. A C++11 compiler would be forbidden from such
49 a transformation. <span class="bold"><strong>Advise</strong></span>: Use <code class="computeroutput"><span class="identifier">memory_order_consume</span></code> only in conjunction
50 with pointer values, as the compiler cannot speculate and transform these
51 into control dependencies.
54 <span class="bold"><strong>Fence operations enforce "too strong" compiler
55 ordering</strong></span>: Semantically, <code class="computeroutput"><span class="identifier">memory_order_acquire</span></code>/<code class="computeroutput"><span class="identifier">memory_order_consume</span></code> and <code class="computeroutput"><span class="identifier">memory_order_release</span></code> need to restrain
56 reordering of memory operations only in one direction. Since there is no
57 way to express this constraint to the compiler, these act as "full
58 compiler barriers" in this implementation. In corner cases this may
59 result in a less efficient code than a C++11 compiler could generate.
62 <span class="bold"><strong>No interprocess fallback</strong></span>: using <code class="computeroutput"><span class="identifier">atomic</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
63 in shared memory only works correctly, if <code class="computeroutput"><span class="identifier">atomic</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">is_lock_free</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">true</span></code>.
67 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
68 <td align="left"></td>
69 <td align="right"><div class="copyright-footer">Copyright © 2011 Helge Bahmann<br>Copyright © 2012 Tim Blechmann<br>Copyright © 2013 Andrey Semashev<p>
70 Distributed under the Boost Software License, Version 1.0. (See accompanying
71 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 <div class="spirit-nav">
77 <a accesskey="p" href="usage_examples.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../atomic.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="porting.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>