Removed signal_threaded uRCU
[libcds.git] / cds / urcu / dispose_thread.h
index 9319560350c27ea984cc0b3d5aaff26a0bbc0e04..d97e37dd11d004c1002d6be4d5933699088a6aef 100644 (file)
@@ -1,4 +1,32 @@
-//$$CDS-header$$1
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (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:
+
+    * 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_URCU_DISPOSE_THREAD_H
 #define CDSLIB_URCU_DISPOSE_THREAD_H
 
 namespace cds { namespace urcu {
 
-    /// Reclamation thread for \p general_threaded and \p signal_threaded URCU
+    /// Reclamation thread for \p general_threaded URCU
     /**
         The object of this class contains a reclamation thread object and
         necessary synchronization object(s). The object manages reclamation thread
         and defines a set of messages (i.e. methods) to communicate with the thread.
 
-        Template argument \p Buffer defines the buffer type of \ref general_threaded (or \ref signal_threaded) URCU.
+        Template argument \p Buffer defines the buffer type of \ref general_threaded URCU.
     */
     template <class Buffer>
     class dispose_thread
@@ -54,15 +82,15 @@ namespace cds { namespace urcu {
         condvar_type    m_cvDataReady;
 
         // Task for thread (dispose cycle)
-        atomics::atomic<buffer_type *>  m_pBuffer;
-        uint64_t volatile      m_nCurEpoch;
+        atomics::atomic<buffer_type *>  m_pBuffer{ nullptr };
+        uint64_t m_nCurEpoch = 0;
 
         // Quit flag
-        atomics::atomic<bool>  m_bQuit;
+        bool    m_bQuit = false;
 
         // disposing pass sync
-        condvar_type           m_cvReady;
-        atomics::atomic<bool>  m_bReady;
+        condvar_type        m_cvReady;
+        bool                m_bReady = false;
         //@endcond
 
     private: // methods called from disposing thread
@@ -78,7 +106,7 @@ namespace cds { namespace urcu {
                 // signal that we are ready to dispose
                 {
                     unique_lock lock( m_Mutex );
-                    m_bReady.store( true, atomics::memory_order_relaxed );
+                    m_bReady = true;
                 }
                 m_cvReady.notify_one();
 
@@ -90,9 +118,9 @@ namespace cds { namespace urcu {
                         m_cvDataReady.wait( lock );
 
                     // New work is ready
-                    m_bReady.store( false, atomics::memory_order_relaxed ); // we are busy
+                    m_bReady = false; // we are busy
 
-                    bQuit = m_bQuit.load( atomics::memory_order_relaxed );
+                    bQuit = m_bQuit;
                     nCurEpoch = m_nCurEpoch;
                     m_pBuffer.store( nullptr, atomics::memory_order_relaxed );
                 }
@@ -108,7 +136,7 @@ namespace cds { namespace urcu {
             while ( ( p = pBuf->front()) != nullptr ) {
                 if ( p->m_nEpoch <= nCurEpoch ) {
                     p->free();
-                    CDS_VERIFY( pBuf->pop_front() );
+                    CDS_VERIFY( pBuf->pop_front());
                 }
                 else
                     break;
@@ -116,16 +144,6 @@ namespace cds { namespace urcu {
         }
         //@endcond
 
-    public:
-        //@cond
-        dispose_thread()
-            : m_pBuffer( nullptr )
-            , m_nCurEpoch(0)
-            , m_bQuit( false )
-            , m_bReady( false )
-        {}
-        //@endcond
-
     public: // methods called from any thread
         /// Start reclamation thread
         /**
@@ -150,13 +168,13 @@ namespace cds { namespace urcu {
                 unique_lock lock( m_Mutex );
 
                 // wait while retiring pass done
-                while ( !m_bReady.load( atomics::memory_order_relaxed ))
+                while ( !m_bReady )
                     m_cvReady.wait( lock );
 
                 // give a new work and set stop flag
                 m_nCurEpoch = nCurEpoch;
                 m_pBuffer.store( &buf, atomics::memory_order_relaxed );
-                m_bQuit.store( true, atomics::memory_order_relaxed );
+                m_bQuit = true;
             }
             m_cvDataReady.notify_one();
 
@@ -180,11 +198,11 @@ namespace cds { namespace urcu {
                 unique_lock lock( m_Mutex );
 
                 // wait while disposing pass done
-                while ( !m_bReady.load( atomics::memory_order_relaxed ))
+                while ( !m_bReady )
                     m_cvReady.wait( lock );
 
                 // new work
-                m_bReady.store( false, atomics::memory_order_relaxed );
+                m_bReady = false;
                 m_nCurEpoch = nCurEpoch;
                 m_pBuffer.store( &buf, atomics::memory_order_relaxed );
             }
@@ -192,7 +210,7 @@ namespace cds { namespace urcu {
 
             if ( bSync ) {
                 unique_lock lock( m_Mutex );
-                while ( !m_bReady.load( atomics::memory_order_relaxed ))
+                while ( !m_bReady )
                     m_cvReady.wait( lock );
             }
         }