Boost C++ Libraries: Ticket #8135: [lockfree] compile time capacity difference behavior https://svn.boost.org/trac10/ticket/8135 <p> <a class="ext-link" href="http://lists.boost.org/boost-users/2013/02/77649.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2013/02/77649.php</a> </p> <p> I confused with boost::lockfree::queue behavior. </p> <p> Fist, run-time capacity: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/lockfree/queue.hpp&gt; int main() { boost::lockfree::queue&lt;int, boost::lockfree::fixed_sized&lt;true&gt;&gt; que(3); std::cout &lt;&lt; std::boolalpha; std::cout &lt;&lt; que.push(1) &lt;&lt; std::endl; // true std::cout &lt;&lt; que.push(2) &lt;&lt; std::endl; // true std::cout &lt;&lt; que.push(3) &lt;&lt; std::endl; // true std::cout &lt;&lt; que.push(4) &lt;&lt; std::endl; // false } </pre><p> I think this behavior is correct. </p> <p> But, compile-time capacity: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/lockfree/queue.hpp&gt; int main() { boost::lockfree::queue&lt;int, boost::lockfree::capacity&lt;3&gt;&gt; que; std::cout &lt;&lt; std::boolalpha; std::cout &lt;&lt; que.push(1) &lt;&lt; std::endl; // true std::cout &lt;&lt; que.push(2) &lt;&lt; std::endl; // true std::cout &lt;&lt; que.push(3) &lt;&lt; std::endl; // false : why? std::cout &lt;&lt; que.push(4) &lt;&lt; std::endl; // false } </pre><p> Is this bug or specification? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8135 Trac 1.4.3 timblechmann Fri, 22 Feb 2013 09:55:24 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8135#comment:1 https://svn.boost.org/trac10/ticket/8135#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83079" title="lockfree: queue - allocate one element more than required the queue ...">[83079]</a>) lockfree: queue - allocate one element more than required </p> <p> the queue internally uses a dummy node, which is not user-visible. therefore we should allocate one element more than needed </p> <p> fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8135" title="#8135: Bugs: [lockfree] compile time capacity difference behavior (closed: fixed)">#8135</a> </p> Ticket