Merge branch 'flat_combinig_add_stress_and_unint_tests' of https://github.com/mgalimu...
[libcds.git] / cds / urcu / details / sig_threaded.h
index e19d536a5cc5b42a957dc45abc5b5bc826eca1b9..bac724b3b1f64b659460848a663e375d869408be 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_DETAILS_SIG_THREADED_H
 #define CDSLIB_URCU_DETAILS_SIG_THREADED_H
@@ -30,18 +58,18 @@ namespace cds { namespace urcu {
         that provides unified RCU interface. You should use this wrapper class instead \p %signal_threaded
 
         Template arguments:
-        - \p Buffer - buffer type with FIFO semantics. Default is cds::container::VyukovMPMCCycleQueue. See \ref signal_buffered
+        - \p Buffer - buffer type with FIFO semantics. Default is \p cds::container::VyukovMPSCCycleQueue. See \ref signal_buffered
             for description of buffer's interface. The buffer contains the objects of \ref epoch_retired_ptr
             type that contains additional \p m_nEpoch field. This field specifies an epoch when the object
             has been placed into the buffer. The \p %signal_threaded object has a global epoch counter
-            that is incremented on each \p synchronize call. The epoch is used internally to prevent early deletion.
+            that is incremented on each \p synchronize() call. The epoch is used internally to prevent early deletion.
         - \p Lock - mutex type, default is \p std::mutex
         - \p DisposerThread - the reclamation thread class. Default is \ref cds::urcu::dispose_thread,
             see the description of this class for required interface.
         - \p Backoff - back-off schema, default is cds::backoff::Default
     */
     template <
-        class Buffer = cds::container::VyukovMPMCCycleQueue< epoch_retired_ptr >
+        class Buffer = cds::container::VyukovMPSCCycleQueue< epoch_retired_ptr >
         ,class Lock = std::mutex
         ,class DisposerThread = dispose_thread<Buffer>
         ,class Backoff = cds::backoff::Default
@@ -88,7 +116,7 @@ namespace cds { namespace urcu {
         /// Returns singleton instance
         static signal_threaded * instance()
         {
-            return static_cast<signal_threaded *>( base_class::instance() );
+            return static_cast<signal_threaded *>( base_class::instance());
         }
         /// Checks if the singleton is created and ready to use
         static bool isUsed()
@@ -109,7 +137,7 @@ namespace cds { namespace urcu {
         bool push_buffer( epoch_retired_ptr&& p )
         {
             bool bPushed = m_Buffer.push( p );
-            if ( !bPushed || m_Buffer.size() >= capacity() ) {
+            if ( !bPushed || m_Buffer.size() >= capacity()) {
                 synchronize();
                 if ( !bPushed ) {
                     p.free();
@@ -136,7 +164,7 @@ namespace cds { namespace urcu {
         static void Construct( size_t nBufferCapacity = 256, int nSignal = SIGUSR1 )
         {
             if ( !singleton_ptr::s_pRCU ) {
-                std::unique_ptr< signal_threaded, scoped_disposer > pRCU( new signal_threaded( nBufferCapacity, nSignal ) );
+                std::unique_ptr< signal_threaded, scoped_disposer > pRCU( new signal_threaded( nBufferCapacity, nSignal ));
                 pRCU->m_DisposerThread.start();
 
                 singleton_ptr::s_pRCU = pRCU.release();
@@ -146,7 +174,7 @@ namespace cds { namespace urcu {
         /// Destroys singleton object and terminates internal reclamation thread
         static void Destruct( bool bDetachAll = false )
         {
-            if ( isUsed() ) {
+            if ( isUsed()) {
                 signal_threaded * pThis = instance();
                 if ( bDetachAll )
                     pThis->m_ThreadList.detach_all();
@@ -242,6 +270,19 @@ namespace cds { namespace urcu {
             return base_class::signal_no();
         }
     };
+
+
+    /// User-space signal-handled RCU with deferred threaded reclamation (stripped version)
+    /**
+        @headerfile cds/urcu/signal_threaded.h
+
+        This short version of \p signal_threaded is intended for stripping debug info.
+        If you use \p %signal_threaded with default template arguments you may use
+        this stripped version. All functionality of both classes are identical.
+    */
+    class signal_threaded_stripped: public signal_threaded<>
+    {};
+
 }} // namespace cds::urcu
 
 #endif // #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED