Renamed get_result typedef to raw_ptr
[libcds.git] / cds / container / fcpriority_queue.h
index 2e56f561e5376a442ceddc8da3f1e15b3fad0578..163537ed778e6462c075e1dd2260477d3f50dffa 100644 (file)
@@ -111,7 +111,8 @@ namespace cds { namespace container {
             op_push = cds::algo::flat_combining::req_Operation,
             op_push_move,
             op_pop,
-            op_clear
+            op_clear,
+            op_empty
         };
 
         // Flat combining publication list record
@@ -231,10 +232,14 @@ namespace cds { namespace container {
         /**
             If the combining is in process the function waits while combining done.
         */
-        bool empty() const
+        bool empty()
         {
-            m_FlatCombining.wait_while_combining();
-            return m_PQueue.empty();
+            fc_record * pRec = m_FlatCombining.acquire_record();
+
+            m_FlatCombining.combine( op_empty, pRec, *this );
+            assert( pRec->is_done() );
+            m_FlatCombining.release_record( pRec );
+            return pRec->bEmpty;
         }
 
         /// Internal statistics
@@ -254,6 +259,9 @@ namespace cds { namespace container {
         {
             assert( pRec );
 
+            // this function is called under FC mutex, so switch TSan off
+            CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
+
             switch ( pRec->op() ) {
             case op_push:
                 assert( pRec->pValPush );
@@ -275,10 +283,15 @@ namespace cds { namespace container {
                 while ( !m_PQueue.empty() )
                     m_PQueue.pop();
                 break;
+            case op_empty:
+                pRec->bEmpty = m_PQueue.empty();
+                break;
             default:
                 assert(false);
                 break;
             }
+
+            CDS_TSAN_ANNOTATE_IGNORE_RW_END;
         }
         //@endcond
     };