MSPriorityQueue: removed monotonic_counter due its horrible performance
[libcds.git] / cds / container / mspriority_queue.h
index a99c8193d65a3ba45d8a218870632c0c1242a8b2..cde914543c764237131fcfd974531d199e4149ed 100644 (file)
@@ -1,7 +1,35 @@
-//$$CDS-header$$
-
-#ifndef __CDS_CONTAINER_MSPRIORITY_QUEUE_H
-#define __CDS_CONTAINER_MSPRIORITY_QUEUE_H
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CDSLIB_CONTAINER_MSPRIORITY_QUEUE_H
+#define CDSLIB_CONTAINER_MSPRIORITY_QUEUE_H
 
 #include <memory>
 #include <cds/container/details/base.h>
@@ -15,10 +43,10 @@ namespace cds { namespace container {
     namespace mspriority_queue {
 
 #ifdef CDS_DOXYGEN_INVOKED
-        /// Synonym for cds::intrusive::mspriority_queue::stat
+        /// Synonym for \p cds::intrusive::mspriority_queue::stat
         typedef cds::intrusive::mspriority_queue::stat<> stat;
 
-        /// Synonym for cds::intrusive::mspriority_queue::empty_stat
+        /// Synonym for \p cds::intrusive::mspriority_queue::empty_stat
         typedef cds::intrusive::mspriority_queue::empty_stat empty_stat;
 #else
         using cds::intrusive::mspriority_queue::stat;
@@ -48,8 +76,8 @@ namespace cds { namespace container {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::buffer - the buffer type for heap array. Possible type are: \p opt::v::static_buffer, \p opt::v::dynamic_buffer.
-                Default is \p %opt::v::dynamic_buffer.
+            - \p opt::buffer - the buffer type for heap array. Possible type are: \p opt::v::initiaized_static_buffer, \p opt::v::initialized_dynamic_buffer.
+                Default is \p %opt::v::initialized_dynamic_buffer.
                 You may specify any type of values for the buffer since at instantiation time
                 the \p buffer::rebind member metafunction is called to change the type of values stored in the buffer.
             - \p opt::compare - priority compare functor. No default functor is provided.
@@ -63,7 +91,7 @@ namespace cds { namespace container {
                 If the compiler supports move semantics it would be better to specify the move policy
                 based on the move semantics for type \p T.
             - \p opt::stat - internal statistics. Available types: \p mspriority_queue::stat, \p mspriority_queue::empty_stat (the default, no overhead)
-        */
+            */
         template <typename... Options>
         struct make_traits {
 #   ifdef CDS_DOXYGEN_INVOKED
@@ -114,11 +142,12 @@ namespace cds { namespace container {
         typedef Traits      traits      ;   ///< Traits template parameter
 
         typedef typename base_class::key_comparator key_comparator; ///< priority comparing functor based on opt::compare and opt::less option setter.
-        typedef typename base_class::lock_type lock_type; ///< heap's size lock type
-        typedef typename base_class::back_off  back_off ; ///< Back-off strategy
-        typedef typename base_class::stat          stat ; ///< internal statistics type
+        typedef typename base_class::lock_type lock_type;   ///< heap's size lock type
+        typedef typename base_class::back_off  back_off ;   ///< Back-off strategy
+        typedef typename traits::stat          stat;        ///< internal statistics type, see \p intrusive::mspriority_queue::traits::stat
+        typedef typename base_class::item_counter  item_counter;///< Item counter type
         typedef typename traits::allocator::template rebind<value_type>::other allocator_type; ///< Value allocator
-        typedef typename traits::move_policy move_policy; ///< Move policy for type \p T
+        typedef typename traits::move_policy   move_policy; ///< Move policy for type \p T
 
     protected:
         //@cond
@@ -136,7 +165,7 @@ namespace cds { namespace container {
     public:
         /// Constructs empty priority queue
         /**
-            For cds::opt::v::static_buffer the \p nCapacity parameter is ignored.
+            For \p cds::opt::v::initialized_static_buffer the \p nCapacity parameter is ignored.
         */
         MSPriorityQueue( size_t nCapacity )
             : base_class( nCapacity )
@@ -223,7 +252,7 @@ namespace cds { namespace container {
         */
         bool pop( value_type& dest )
         {
-            return pop_with( [&dest]( value_type& src ) { move_policy()(dest, src); } );
+            return pop_with( [&dest]( value_type& src ) { move_policy()(dest, std::move(src)); });
         }
 
         /// Extracts an item with high priority
@@ -313,4 +342,4 @@ namespace cds { namespace container {
 
 }} // namespace cds::container
 
-#endif // #ifndef __CDS_CONTAINER_MSPRIORITY_QUEUE_H
+#endif // #ifndef CDSLIB_CONTAINER_MSPRIORITY_QUEUE_H