Added simplified form of urcu::batch_retire function
[libcds.git] / cds / urcu / details / gpi.h
index 1e5426ba0be212c90641f8110104b9eb7b210110..776a09fcc870ee57aa17b920d1e3cf5cd1cba329 100644 (file)
@@ -111,11 +111,8 @@ namespace cds { namespace urcu {
         virtual void retire_ptr( retired_ptr& p )
         {
             synchronize();
-            if ( p.m_p ) {
-                // TSan ignores atomic_thread_fence in synchronize()
-                //CDS_TSAN_ANNOTATE_HAPPENS_BEFORE( p.m_p );
+            if ( p.m_p )
                 p.free();
-            }
         }
 
         /// Retires the pointer chain [\p itFirst, \p itLast)
@@ -127,15 +124,24 @@ namespace cds { namespace urcu {
                 while ( itFirst != itLast ) {
                     retired_ptr p( *itFirst );
                     ++itFirst;
-                    if ( p.m_p ) {
-                        // TSan ignores atomic_thread_fence in synchronize()
-                        //CDS_TSAN_ANNOTATE_HAPPENS_BEFORE( p.m_p );
+                    if ( p.m_p )
                         p.free();
-                    }
                 }
             }
         }
 
+        /// Retires the pointer chain until \p Func returns \p nullptr retired pointer
+        template <typename Func>
+        void batch_retire( Func e )
+        {
+            retired_ptr p{ e() };
+            if ( p.m_p ) {
+                synchronize();
+                for ( ; p.m_p; p = e() )
+                    p.free();
+            }
+        }
+
         /// Waits to finish a grace period
         void synchronize()
         {