Adds a few single-threaded test cases for queue, stack, and set
[libcds.git] / cds / intrusive / fcstack.h
index 553ac903c928912eccbc52443ed8c6229202ffc1..257079b03a758935b36ae96bcb93d0651769cab1 100644 (file)
@@ -1,11 +1,11 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     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:
 
@@ -25,7 +25,7 @@
     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.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSLIB_INTRUSIVE_FCSTACK_H
@@ -188,7 +188,7 @@ namespace cds { namespace intrusive {
             else
                 m_FlatCombining.combine( op_push, pRec, *this );
 
-            assert( pRec->is_done() );
+            assert( pRec->is_done());
             m_FlatCombining.release_record( pRec );
             m_FlatCombining.internal_statistics().onPush();
             return true;
@@ -205,7 +205,7 @@ namespace cds { namespace intrusive {
             else
                 m_FlatCombining.combine( op_pop, pRec, *this );
 
-            assert( pRec->is_done() );
+            assert( pRec->is_done());
             m_FlatCombining.release_record( pRec );
 
             m_FlatCombining.internal_statistics().onPop( pRec->bEmpty );
@@ -226,7 +226,7 @@ namespace cds { namespace intrusive {
             else
                 m_FlatCombining.combine( bDispose ? op_clear_and_dispose : op_clear, pRec, *this );
 
-            assert( pRec->is_done() );
+            assert( pRec->is_done());
             m_FlatCombining.release_record( pRec );
         }
 
@@ -259,7 +259,6 @@ namespace cds { namespace intrusive {
             return m_FlatCombining.statistics();
         }
 
-
     public: // flat combining cooperation, not for direct use!
         //@cond
         /// Flat combining supporting function. Do not call it directly!
@@ -272,12 +271,10 @@ namespace cds { namespace intrusive {
         {
             assert( pRec );
 
-            // this function is called under FC mutex, so switch TSan off
-            CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
-            switch ( pRec->op() ) {
+            switch ( pRec->op()) {
             case op_push:
                 assert( pRec->pVal );
-                m_Stack.push_front( *(pRec->pVal ) );
+                m_Stack.push_front( *(pRec->pVal ));
                 break;
             case op_pop:
                 pRec->bEmpty = m_Stack.empty();
@@ -290,24 +287,20 @@ namespace cds { namespace intrusive {
                 m_Stack.clear();
                 break;
             case op_clear_and_dispose:
-                m_Stack.clear_and_dispose( disposer() );
+                m_Stack.clear_and_dispose( disposer());
                 break;
             default:
                 assert(false);
                 break;
             }
-            CDS_TSAN_ANNOTATE_IGNORE_RW_END;
         }
 
         /// Batch-processing flat combining
         void fc_process( typename fc_kernel::iterator itBegin, typename fc_kernel::iterator itEnd )
         {
-            // this function is called under FC mutex, so switch TSan off
-            CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
-
             typedef typename fc_kernel::iterator fc_iterator;
             for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
-                switch ( it->op() {
+                switch ( it->op( atomics::memory_order_acquire )) {
                 case op_push:
                 case op_pop:
                     if ( itPrev != itEnd && collide( *itPrev, *it ))
@@ -317,7 +310,6 @@ namespace cds { namespace intrusive {
                     break;
                 }
             }
-            CDS_TSAN_ANNOTATE_IGNORE_RW_END;
         }
         //@endcond
 
@@ -325,7 +317,7 @@ namespace cds { namespace intrusive {
         //@cond
         bool collide( fc_record& rec1, fc_record& rec2 )
         {
-            switch ( rec1.op() ) {
+            switch ( rec1.op()) {
                 case op_push:
                     if ( rec2.op() == op_pop ) {
                         assert(rec1.pVal);