Fixed Clang build
[libcds.git] / cds / intrusive / mspriority_queue.h
index 9128fca83a91cfd8e6ae7cc0b04b297d263ae441..7b8476e4a202f54676ce8ff510bbc4ddc0f31f5e 100644 (file)
@@ -93,34 +93,6 @@ namespace cds { namespace intrusive {
             //@endcond
         };
 
-        class monotonic_counter
-        {
-        public:
-            typedef size_t counter_type;
-
-            monotonic_counter()
-                : m_nCounter(0)
-            {}
-
-            size_t inc()
-            {
-                return ++m_nCounter;
-            }
-
-            size_t dec()
-            {
-                return m_nCounter--;
-            }
-
-            size_t value() const
-            {
-                return m_nCounter;
-            }
-
-        private:
-            size_t m_nCounter;
-        };
-
         /// MSPriorityQueue traits
         struct traits {
             /// Storage type
@@ -157,12 +129,6 @@ namespace cds { namespace intrusive {
                 or any other with interface like \p %mspriority_queue::stat
             */
             typedef empty_stat      stat;
-
-            /// Item counter type
-            typedef cds::bitop::bit_reverse_counter<> item_counter;
-
-            /// Fairness
-            static bool const fairness = true;
         };
 
         /// Metafunction converting option list to traits
@@ -232,9 +198,10 @@ namespace cds { namespace intrusive {
         typedef typename opt::details::make_comparator< value_type, traits >::type key_comparator;
 #   endif
 
-        typedef typename traits::lock_type lock_type;   ///< heap's size lock type
-        typedef typename traits::back_off  back_off;    ///< Back-off strategy
-        typedef typename traits::stat      stat;        ///< internal statistics type
+        typedef typename traits::lock_type      lock_type;   ///< heap's size lock type
+        typedef typename traits::back_off       back_off;    ///< Back-off strategy
+        typedef typename traits::stat           stat;        ///< internal statistics type, see \p mspriority_queue::traits::stat
+        typedef typename cds::bitop::bit_reverse_counter<> item_counter;///< Item counter type
 
     protected:
         //@cond
@@ -277,14 +244,11 @@ namespace cds { namespace intrusive {
         typedef typename traits::buffer::template rebind<node>::other   buffer_type ;   ///< Heap array buffer type
 
         //@cond
-        typedef typename traits::item_counter  item_counter_type;
-        typedef typename item_counter_type::counter_type    counter_type;
+        typedef typename item_counter::counter_type    counter_type;
         //@endcond
 
-        static const bool c_bFairQueue = traits::fairness;
-
     protected:
-        item_counter_type   m_ItemCounter   ;   ///< Item counter
+        item_counter        m_ItemCounter   ;   ///< Item counter
         mutable lock_type   m_Lock          ;   ///< Heap's size lock
         buffer_type         m_Heap          ;   ///< Heap array
         stat                m_Stat          ;   ///< internal statistics accumulator
@@ -365,18 +329,17 @@ namespace cds { namespace intrusive {
             assert( nBottom < m_Heap.capacity() );
             assert( nBottom > 0 );
 
-            if ( c_bFairQueue ) {
-                refTop.lock();
-                if ( nBottom == 1 ) {
-                    refTop.m_nTag = tag_type( Empty );
-                    value_type * pVal = refTop.m_pVal;
-                    refTop.m_pVal = nullptr;
-                    refTop.unlock();
-                    m_Lock.unlock();
-                    m_Stat.onPopSuccess();
-                    return pVal;
-                }
+            refTop.lock();
+            if ( nBottom == 1 ) {
+                refTop.m_nTag = tag_type( Empty );
+                value_type * pVal = refTop.m_pVal;
+                refTop.m_pVal = nullptr;
+                refTop.unlock();
+                m_Lock.unlock();
+                m_Stat.onPopSuccess();
+                return pVal;
             }
+
             node& refBottom = m_Heap[nBottom];
             refBottom.lock();
             m_Lock.unlock();
@@ -385,10 +348,6 @@ namespace cds { namespace intrusive {
             refBottom.m_pVal = nullptr;
             refBottom.unlock();
 
-            //node& refTop = m_Heap[ 1 ];
-            if ( !c_bFairQueue )
-                refTop.lock();
-
             if ( refTop.m_nTag == tag_type(Empty) ) {
                 // nBottom == nTop
                 refTop.unlock();