Precizing buffer type for MSPriorityQueue
authorkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 08:32:15 +0000 (11:32 +0300)
committerkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 08:32:15 +0000 (11:32 +0300)
cds/intrusive/mspriority_queue.h
cds/opt/buffer.h
test/stress/pqueue/pop.cpp

index 2dda9d37883d976c90f877f035380de414bbe125..e3d211efa82212464db8689218cfa425f59deda4 100644 (file)
@@ -240,7 +240,7 @@ namespace cds { namespace intrusive {
         //@endcond
 
     public:
-        typedef typename traits::buffer::template rebind<node>::other   buffer_type ;   ///< Heap array buffer type
+        typedef typename traits::buffer::template rebind<node, typename traits::buffer::allocator, false>::other   buffer_type ;   ///< Heap array buffer type
 
         //@cond
         typedef cds::bitop::bit_reverse_counter<>           item_counter_type;
index 76dc4cf1066422726d56dc434435d3558d32bfd2..c54d1d5d473ec1a0e8c36c449d6ad5de4e2c877d 100644 (file)
@@ -286,17 +286,18 @@ namespace cds { namespace opt {
         class uninitialized_dynamic_buffer
         {
         public:
-            typedef T   value_type;   ///< Value type
+            typedef T     value_type;   ///< Value type
+            typedef Alloc allocator;    ///< Allocator type;
             static CDS_CONSTEXPR const bool c_bExp2 = Exp2; ///< \p Exp2 flag
 
             /// Rebind buffer for other template parameters
-            template <typename Q, typename Alloc2=Alloc, bool Exp22 = c_bExp2>
+            template <typename Q, typename Alloc2= allocator, bool Exp22 = c_bExp2>
             struct rebind {
                 typedef uninitialized_dynamic_buffer<Q, Alloc2, Exp22> other;  ///< Rebinding result type
             };
 
             //@cond
-            typedef typename Alloc::template rebind<value_type>::other allocator_type;
+            typedef typename allocator::template rebind<value_type>::other allocator_type;
             //@endcond
 
         private:
@@ -387,17 +388,18 @@ namespace cds { namespace opt {
         class initialized_dynamic_buffer
         {
         public:
-            typedef T   value_type;   ///< Value type
+            typedef T     value_type;   ///< Value type
+            typedef Alloc allocator;    ///< Allocator type
             static CDS_CONSTEXPR const bool c_bExp2 = Exp2; ///< \p Exp2 flag
 
             /// Rebind buffer for other template parameters
-            template <typename Q, typename Alloc2=Alloc, bool Exp22 = c_bExp2>
+            template <typename Q, typename Alloc2= allocator, bool Exp22 = c_bExp2>
             struct rebind {
                 typedef initialized_dynamic_buffer<Q, Alloc2, Exp22> other;  ///< Rebinding result type
             };
 
             //@cond
-            typedef cds::details::Allocator<value_type, Alloc>   allocator_type;
+            typedef cds::details::Allocator<value_type, allocator>   allocator_type;
             //@endcond
 
         private:
index 8127b0b9b492d173cb46258ae07ac9c0ccb3a127..75704ed70d1922037b5ffd220030e828162344a9 100644 (file)
@@ -70,6 +70,7 @@ namespace {
                     ++m_nPopSuccess;
                     nPrevKey = val.key;
 
+                    /*
                     while ( !m_Queue.empty() ) {
                         if ( m_Queue.pop( val )) {
                             ++m_nPopSuccess;
@@ -86,6 +87,21 @@ namespace {
                         else
                             ++m_nPopFailed;
                     }
+                    */
+
+                    while ( m_Queue.pop( val )) {
+                        ++m_nPopSuccess;
+                        if ( val.key > nPrevKey ) {
+                            ++m_nPopError;
+                            m_arrFailedPops.emplace_back( failed_pops{ nPrevKey, val.key } );
+                        }
+                        else if ( val.key == nPrevKey ) {
+                            ++m_nPopErrorEq;
+                            m_arrFailedPops.emplace_back( failed_pops{ nPrevKey, val.key } );
+                        }
+                        nPrevKey = val.key;
+                    }
+
                 }
                 else
                     ++m_nPopFailed;