Moved priority_queue unit test to gtest framework
[libcds.git] / cds / intrusive / segmented_queue.h
index d10ab14b27e0b986b4cdeb83d3781c91a1875a4d..dfb93882d32f6dd7b313ba87c10d91b68b49d8b7 100644 (file)
@@ -1,13 +1,41 @@
-//$$CDS-header$$
-
-#ifndef __CDS_INTRUSIVE_SEGMENTED_QUEUE_H
-#define __CDS_INTRUSIVE_SEGMENTED_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_INTRUSIVE_SEGMENTED_QUEUE_H
+#define CDSLIB_INTRUSIVE_SEGMENTED_QUEUE_H
 
 #include <mutex>
 #include <cds/intrusive/details/base.h>
 #include <cds/details/marked_ptr.h>
 #include <cds/algo/int_algo.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/opt/permutation.h>
 
 #include <boost/intrusive/slist.hpp>
@@ -105,7 +133,7 @@ namespace cds { namespace intrusive {
             typedef CDS_DEFAULT_ALLOCATOR allocator;
 
             /// Lock type used to maintain an internal list of allocated segments
-            typedef cds::lock::Spin lock_type;
+            typedef cds::sync::spin lock_type;
 
             /// Random \ref cds::opt::permutation_generator "permutation generator" for sequence [0, quasi_factor)
             typedef cds::opt::v::random2_permutation<int>    permutation_generator;
@@ -211,7 +239,7 @@ namespace cds { namespace intrusive {
         typedef typename traits::lock_type     lock_type;   ///< Type of mutex for maintaining an internal list of allocated segments.
         typedef typename traits::permutation_generator permutation_generator; ///< Random permutation generator for sequence [0, quasi-factor)
 
-        static const size_t m_nHazardPtrCount = 2 ; ///< Count of hazard pointer required for the algorithm
+        static const size_t c_nHazardPtrCount = 2 ; ///< Count of hazard pointer required for the algorithm
 
     protected:
         //@cond
@@ -352,7 +380,7 @@ namespace cds { namespace intrusive {
                 m_Stat.onSegmentCreated();
 
                 if ( m_List.empty() )
-                    m_pHead.store( pNew, memory_model::memory_order_relaxed );
+                    m_pHead.store( pNew, memory_model::memory_order_release );
                 m_List.push_back( *pNew );
                 m_pTail.store( pNew, memory_model::memory_order_release );
                 return guard.assign( pNew );
@@ -411,8 +439,7 @@ namespace cds { namespace intrusive {
 
             segment * allocate_segment()
             {
-                return segment_allocator().NewBlock( sizeof(segment) + sizeof(cell) * m_nQuasiFactor,
-                    quasi_factor() );
+                return segment_allocator().NewBlock( sizeof(segment) + sizeof(cell) * m_nQuasiFactor, quasi_factor() );
             }
 
             static void free_segment( segment * pSegment )
@@ -691,4 +718,4 @@ namespace cds { namespace intrusive {
 #   pragma warning( pop )
 #endif
 
-#endif // #ifndef __CDS_INTRUSIVE_SEGMENTED_QUEUE_H
+#endif // #ifndef CDSLIB_INTRUSIVE_SEGMENTED_QUEUE_H