]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/lockfree/spsc_queue.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / lockfree / spsc_queue.hpp
index 7903d2cdf3fb7ab93914b6e965099c5d8f101ff3..a0a779de7a9ea03500a79b27f6cbde359ce14fd3 100644 (file)
@@ -16,7 +16,9 @@
 #include <boost/aligned_storage.hpp>
 #include <boost/assert.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/core/allocator_access.hpp>
 #include <boost/utility.hpp>
+#include <boost/next_prior.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/config.hpp> // for BOOST_LIKELY
 
@@ -522,7 +524,12 @@ class runtime_sized_ringbuffer:
 {
     typedef std::size_t size_type;
     size_type max_elements_;
+#ifdef BOOST_NO_CXX11_ALLOCATOR
     typedef typename Alloc::pointer pointer;
+#else
+    typedef std::allocator_traits<Alloc> allocator_traits;
+    typedef typename allocator_traits::pointer pointer;
+#endif
     pointer array_;
 
 protected:
@@ -535,20 +542,35 @@ public:
     explicit runtime_sized_ringbuffer(size_type max_elements):
         max_elements_(max_elements + 1)
     {
+#ifdef BOOST_NO_CXX11_ALLOCATOR
         array_ = Alloc::allocate(max_elements_);
+#else
+        Alloc& alloc = *this;
+        array_ = allocator_traits::allocate(alloc, max_elements_);
+#endif
     }
 
     template <typename U>
-    runtime_sized_ringbuffer(typename Alloc::template rebind<U>::other const & alloc, size_type max_elements):
+    runtime_sized_ringbuffer(typename boost::allocator_rebind<Alloc, U>::type const & alloc, size_type max_elements):
         Alloc(alloc), max_elements_(max_elements + 1)
     {
+#ifdef BOOST_NO_CXX11_ALLOCATOR
         array_ = Alloc::allocate(max_elements_);
+#else
+        Alloc& allocator = *this;
+        array_ = allocator_traits::allocate(allocator, max_elements_);
+#endif
     }
 
     runtime_sized_ringbuffer(Alloc const & alloc, size_type max_elements):
         Alloc(alloc), max_elements_(max_elements + 1)
     {
+#ifdef BOOST_NO_CXX11_ALLOCATOR
         array_ = Alloc::allocate(max_elements_);
+#else
+        Alloc& allocator = *this;
+        array_ = allocator_traits::allocate(allocator, max_elements_);
+#endif
     }
 
     ~runtime_sized_ringbuffer(void)
@@ -557,7 +579,12 @@ public:
         T out;
         while (pop(&out, 1)) {}
 
+#ifdef BOOST_NO_CXX11_ALLOCATOR
         Alloc::deallocate(array_, max_elements_);
+#else
+        Alloc& allocator = *this;
+        allocator_traits::deallocate(allocator, array_, max_elements_);
+#endif
     }
 
     bool push(T const & t)
@@ -722,51 +749,72 @@ public:
      *
      *  \pre spsc_queue must be configured to be sized at compile-time
      */
-    // @{
     spsc_queue(void)
     {
+        // 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(!runtime_sized);
     }
 
+    /** Constructs a spsc_queue with a custom allocator
+     *
+     *  \pre spsc_queue must be configured to be sized at compile-time
+     *
+     *  \note This is just for API compatibility: an allocator isn't actually needed
+     */
     template <typename U>
-    explicit spsc_queue(typename allocator::template rebind<U>::other const &)
+    explicit spsc_queue(typename boost::allocator_rebind<allocator, U>::type const &)
     {
-        // just for API compatibility: we don't actually need an allocator
         BOOST_STATIC_ASSERT(!runtime_sized);
     }
 
+    /** Constructs a spsc_queue with a custom allocator
+     *
+     *  \pre spsc_queue must be configured to be sized at compile-time
+     *
+     *  \note This is just for API compatibility: an allocator isn't actually needed
+     */
     explicit spsc_queue(allocator const &)
     {
-        // just for API compatibility: we don't actually need an allocator
+        // 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(!runtime_sized);
     }
-    // @}
-
 
     /** Constructs a spsc_queue for element_count elements
      *
      *  \pre spsc_queue must be configured to be sized at run-time
      */
-    // @{
     explicit spsc_queue(size_type element_count):
         base_type(element_count)
     {
+        // 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(runtime_sized);
     }
 
+    /** Constructs a spsc_queue for element_count elements with a custom allocator
+     *
+     *  \pre spsc_queue must be configured to be sized at run-time
+     */
     template <typename U>
-    spsc_queue(size_type element_count, typename allocator::template rebind<U>::other const & alloc):
+    spsc_queue(size_type element_count, typename boost::allocator_rebind<allocator, U>::type const & alloc):
         base_type(alloc, element_count)
     {
         BOOST_STATIC_ASSERT(runtime_sized);
     }
 
+    /** Constructs a spsc_queue for element_count elements with a custom allocator
+     *
+     *  \pre spsc_queue must be configured to be sized at run-time
+     */
     spsc_queue(size_type element_count, allocator_arg const & alloc):
         base_type(alloc, element_count)
     {
+        // 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(runtime_sized);
     }
-    // @}
 
     /** Pushes object t to the ringbuffer.
      *