]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/lockfree/queue.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / lockfree / queue.hpp
index c8970bbce29962b2d68844b21fe0f5c513d99166..fecbbc07e6dd0bf0e661f7dcd448170de8da9250 100644 (file)
 
 #include <boost/assert.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/core/allocator_access.hpp>
 #include <boost/type_traits/has_trivial_assign.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
 #include <boost/config.hpp> // for BOOST_LIKELY & BOOST_ALIGNMENT
 
-#include <boost/lockfree/detail/allocator_rebind_helper.hpp>
 #include <boost/lockfree/detail/atomic.hpp>
 #include <boost/lockfree/detail/copy_payload.hpp>
 #include <boost/lockfree/detail/freelist.hpp>
@@ -117,7 +117,7 @@ private:
         typedef typename detail::select_tagged_handle<node, node_based>::handle_type handle_type;
 
         node(T const & v, handle_type null_handle):
-            next(tagged_node_handle(null_handle, 0)), data(v)
+            data(v)
         {
             /* increment tag to avoid ABA problem */
             tagged_node_handle old_next = next.load(memory_order_relaxed);
@@ -178,19 +178,27 @@ public:
         return head_.is_lock_free() && tail_.is_lock_free() && pool.is_lock_free();
     }
 
-    //! Construct queue
-    // @{
+    /** Construct a fixed-sized queue
+     *
+     *  \pre Must specify a capacity<> argument
+     * */
     queue(void):
         head_(tagged_node_handle(0, 0)),
         tail_(tagged_node_handle(0, 0)),
         pool(node_allocator(), capacity)
     {
+        // Don't use BOOST_STATIC_ASSERT() here since it will be evaluated when compiling
+        // this function and this function may be compiled even when it isn't being used.
         BOOST_ASSERT(has_capacity);
         initialize();
     }
 
+    /** Construct a fixed-sized queue with a custom allocator
+     *
+     *  \pre Must specify a capacity<> argument
+     * */
     template <typename U>
-    explicit queue(typename detail::allocator_rebind_helper<node_allocator, U>::type const & alloc):
+    explicit queue(typename boost::allocator_rebind<node_allocator, U>::type const & alloc):
         head_(tagged_node_handle(0, 0)),
         tail_(tagged_node_handle(0, 0)),
         pool(alloc, capacity)
@@ -199,29 +207,46 @@ public:
         initialize();
     }
 
+    /** Construct a fixed-sized queue with a custom allocator
+     *
+     *  \pre Must specify a capacity<> argument
+     * */
     explicit queue(allocator const & alloc):
         head_(tagged_node_handle(0, 0)),
         tail_(tagged_node_handle(0, 0)),
         pool(alloc, capacity)
     {
+        // Don't use BOOST_STATIC_ASSERT() here since it will be evaluated when compiling
+        // this function and this function may be compiled even when it isn't being used.
         BOOST_ASSERT(has_capacity);
         initialize();
     }
-    // @}
 
-    //! Construct queue, allocate n nodes for the freelist.
-    // @{
+    /** Construct a variable-sized queue
+     *
+     *  Allocate n nodes initially for the freelist
+     *
+     *  \pre Must \b not specify a capacity<> argument
+     * */
     explicit queue(size_type n):
         head_(tagged_node_handle(0, 0)),
         tail_(tagged_node_handle(0, 0)),
         pool(node_allocator(), n + 1)
     {
+        // Don't use BOOST_STATIC_ASSERT() here since it will be evaluated when compiling
+        // this function and this function may be compiled even when it isn't being used.
         BOOST_ASSERT(!has_capacity);
         initialize();
     }
 
+    /** Construct a variable-sized queue with a custom allocator
+     *
+     *  Allocate n nodes initially for the freelist
+     *
+     *  \pre Must \b not specify a capacity<> argument
+     * */
     template <typename U>
-    queue(size_type n, typename detail::allocator_rebind_helper<node_allocator, U>::type const & alloc):
+    queue(size_type n, typename boost::allocator_rebind<node_allocator, U>::type const & alloc):
         head_(tagged_node_handle(0, 0)),
         tail_(tagged_node_handle(0, 0)),
         pool(alloc, n + 1)
@@ -229,7 +254,6 @@ public:
         BOOST_STATIC_ASSERT(!has_capacity);
         initialize();
     }
-    // @}
 
     /** \copydoc boost::lockfree::stack::reserve
      * */