Move cds/backoff_strategy.h to cds/algo/backoff_strategy.h
authorkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:29:13 +0000 (19:29 +0400)
committerkhizmax <khizmax@gmail.com>
Thu, 18 Sep 2014 15:29:13 +0000 (19:29 +0400)
13 files changed:
cds/algo/backoff_strategy.h [new file with mode: 0644]
cds/algo/flat_combining.h
cds/backoff_strategy.h [deleted file]
cds/intrusive/base.h
cds/lock/spinlock.h
cds/urcu/details/gpb.h
cds/urcu/details/gpi.h
cds/urcu/details/gpt.h
cds/urcu/details/sig_buffered.h
cds/urcu/details/sig_threaded.h
cds/urcu/dispose_thread.h
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters

diff --git a/cds/algo/backoff_strategy.h b/cds/algo/backoff_strategy.h
new file mode 100644 (file)
index 0000000..24852bb
--- /dev/null
@@ -0,0 +1,426 @@
+//$$CDS-header$$
+
+#ifndef __CDS_BACKOFF_STRATEGY_H
+#define __CDS_BACKOFF_STRATEGY_H
+
+/*
+    Filename: backoff_strategy.h
+    Created 2007.03.01 by Maxim Khiszinsky
+
+    Description:
+         Generic back-off strategies
+
+    Editions:
+    2007.03.01  Maxim Khiszinsky    Created
+    2008.10.02  Maxim Khiszinsky    Backoff action transfers from contructor to operator() for all backoff schemas
+    2009.09.10  Maxim Khiszinsky    reset() function added
+*/
+
+#include <cds/compiler/backoff.h>
+#include <cds/details/std/thread.h>
+#include <cds/details/std/chrono.h>
+
+namespace cds {
+    /// Different backoff schemes
+    /**
+        Back-off schema may be used in lock-free algorithms when the algorithm cannot perform some action because a conflict
+        with the other concurrent operation is encountered. In this case current thread can do another work or can call
+        processor's performance hint.
+
+        The interface of back-off strategy is following:
+        \code
+            struct backoff_strategy {
+                void operator()();
+                template <typename Predicate> bool operator()( Predicate pr );
+                void reset();
+            };
+        \endcode
+
+        \p operator() operator calls back-off strategy's action. It is main part of back-off strategy.
+
+        Interruptible back-off <tt>template < typename Predicate > bool operator()( Predicate pr )</tt>
+        allows to interrupt back-off spinning if \p pr predicate returns \p true.
+        \p Predicate is a functor with the following interface:
+        \code
+        struct predicate {
+            bool operator()();
+        };
+        \endcode
+
+        \p reset() function resets internal state of back-off strategy to initial state. It is required for some
+        back-off strategies, for example, exponential back-off.
+    */
+    namespace backoff {
+
+        /// Empty backoff strategy. Do nothing
+        struct empty {
+            //@cond
+            void operator ()()
+            {}
+
+            template <typename Predicate>
+            bool operator()( Predicate pr )
+            {
+                return pr();
+            }
+
+            void reset()
+            {}
+            //@endcond
+        };
+
+        /// Switch to another thread (yield). Good for thread preemption architecture.
+        struct yield {
+            //@cond
+            void operator ()()
+            {
+                cds_std::this_thread::yield();
+                //OS::yield();
+            }
+
+            template <typename Predicate>
+            bool operator()( Predicate pr )
+            {
+                if ( pr() )
+                    return true;
+                operator()();
+                return false;
+            }
+
+            void reset()
+            {}
+            //@endcond
+        };
+
+        /// Random pause
+        /**
+            This back-off strategy calls processor-specific pause hint instruction
+            if one is available for the processor architecture.
+        */
+        struct pause {
+            //@cond
+            void operator ()()
+            {
+#            ifdef CDS_backoff_pause_defined
+                platform::backoff_pause();
+#            endif
+            }
+
+            template <typename Predicate>
+            bool operator()( Predicate pr )
+            {
+                if ( pr() )
+                    return true;
+                operator()();
+                return false;
+            }
+
+            void reset()
+            {}
+            //@endcond
+        };
+
+        /// Processor hint back-off
+        /**
+            This back-off schema calls performance hint instruction if it is available for current processor.
+            Otherwise, it calls \p nop.
+        */
+        struct hint
+        {
+        //@cond
+            void operator ()()
+            {
+#           if defined(CDS_backoff_hint_defined)
+                platform::backoff_hint();
+#           elif defined(CDS_backoff_nop_defined)
+                platform::backoff_nop();
+#           endif
+            }
+
+            template <typename Predicate>
+            bool operator()( Predicate pr )
+            {
+                if ( pr() )
+                    return true;
+                operator()();
+                return false;
+            }
+
+            void reset()
+            {}
+        //@endcond
+        };
+
+        /// Exponential back-off
+        /**
+            This back-off strategy is composite. It consists of \p SpinBkoff and \p YieldBkoff
+            back-off strategy. In first, the strategy tries to apply repeatedly \p SpinBkoff
+            (spinning phase) until internal counter of failed attempts reaches its maximum
+            spinning value. Then, the strategy transits to high-contention phase
+            where it applies \p YieldBkoff until \p reset() is called.
+            On each spinning iteration the internal spinning counter is doubled.
+
+            Choosing the best value for maximum spinning bound is platform and task specific.
+            In this implementation, the default values for maximum and minimum spinning is statically
+            declared so you can set its value globally for your platform.
+            The third template argument, \p Tag, is used to separate implementation. For
+            example, you may define two \p exponential back-offs that is the best for your task A and B:
+            \code
+
+            #include <cds/algo/backoff_strategy.h>
+            namespace bkoff = cds::backoff;
+
+            struct tagA ;   // tag to select task A implementation
+            struct tagB ;   // tag to select task B implementation
+
+            // // define your back-off specialization
+            typedef bkoff::exponential<bkoff::hint, bkoff::yield, tagA> expBackOffA;
+            typedef bkoff::exponential<bkoff::hint, bkoff::yield, tagB> expBackOffB;
+
+            // // set up the best bounds for task A
+            expBackOffA::s_nExpMin = 32;
+            expBackOffA::s_nExpMax = 1024;
+
+            // // set up the best bounds for task B
+            expBackOffB::s_nExpMin = 2;
+            expBackOffB::s_nExpMax = 512;
+
+            \endcode
+
+            Another way of solving this problem is subclassing \p exponential back-off class:
+            \code
+            #include <cds/algo/backoff_strategy.h>
+            namespace bkoff = cds::backoff;
+            typedef bkoff::exponential<bkoff::hint, bkoff::yield>   base_bkoff;
+
+            class expBackOffA: public base_bkoff
+            {
+            public:
+                expBackOffA()
+                    : base_bkoff( 32, 1024 )
+                    {}
+            };
+
+            class expBackOffB: public base_bkoff
+            {
+            public:
+                expBackOffB()
+                    : base_bkoff( 2, 512 )
+                    {}
+            };
+            \endcode
+        */
+        template <typename SpinBkoff, typename YieldBkoff, typename Tag=void>
+        class exponential
+        {
+        public:
+            typedef SpinBkoff  spin_backoff    ;   ///< spin back-off strategy
+            typedef YieldBkoff yield_backoff   ;   ///< yield back-off strategy
+            typedef Tag         impl_tag        ;   ///< implementation separation tag
+
+            static size_t s_nExpMin ;   ///< Default minimum spinning bound (16)
+            static size_t s_nExpMax ;   ///< Default maximum spinning bound (16384)
+
+        protected:
+            size_t  m_nExpCur   ;   ///< Current spinning
+            size_t  m_nExpMin   ;   ///< Minimum spinning bound
+            size_t  m_nExpMax   ;   ///< Maximum spinning bound
+
+            spin_backoff    m_bkSpin    ;   ///< Spinning (fast-path) phase back-off strategy
+            yield_backoff   m_bkYield   ;   ///< Yield phase back-off strategy
+
+        public:
+            /// Initializes m_nExpMin and m_nExpMax from default s_nExpMin and s_nExpMax respectively
+            exponential()
+                : m_nExpMin( s_nExpMin )
+                , m_nExpMax( s_nExpMax )
+            {
+                m_nExpCur = m_nExpMin;
+            }
+
+            /// Explicitly defined bounds of spinning
+            /**
+                The \p libcds library never calls this ctor.
+            */
+            exponential(
+                size_t nExpMin,     ///< Minimum spinning
+                size_t nExpMax      ///< Maximum spinning
+                )
+                : m_nExpMin( nExpMin )
+                , m_nExpMax( nExpMax )
+            {
+                m_nExpCur = m_nExpMin;
+            }
+
+            //@cond
+            void operator ()()
+            {
+                if ( m_nExpCur <= m_nExpMax ) {
+                    for ( size_t n = 0; n < m_nExpCur; ++n )
+                        m_bkSpin();
+                    m_nExpCur *= 2;
+                }
+                else
+                    m_bkYield();
+            }
+
+            template <typename Predicate>
+            bool operator()( Predicate pr )
+            {
+                if ( m_nExpCur <= m_nExpMax ) {
+                    for ( size_t n = 0; n < m_nExpCur; ++n ) {
+                        if ( m_bkSpin(pr) )
+                            return true;
+                    }
+                    m_nExpCur *= 2;
+                }
+                else
+                    return m_bkYield(pr);
+                return false;
+            }
+
+            void reset()
+            {
+                m_nExpCur = m_nExpMin;
+                m_bkSpin.reset();
+                m_bkYield.reset();
+            }
+            //@endcond
+        };
+
+        //@cond
+        template <typename SpinBkoff, typename YieldBkoff, typename Tag>
+        size_t exponential<SpinBkoff, YieldBkoff, Tag>::s_nExpMin = 16;
+
+        template <typename SpinBkoff, typename YieldBkoff, typename Tag>
+        size_t exponential<SpinBkoff, YieldBkoff, Tag>::s_nExpMax = 16 * 1024;
+        //@endcond
+
+        /// Delay back-off strategy
+        /**
+            Template arguments:
+            - \p Duration - duration type, default is \p std::chrono::milliseconds
+            - \p Tag - a selector tag
+
+            Choosing the best value for th timeout is platform and task specific.
+            In this implementation, the default values for timeout is statically
+            declared so you can set its value globally for your platform.
+            The second template argument, \p Tag, is used to separate implementation. For
+            example, you may define two \p delay back-offs for 5 and 10 ms timeout:
+            \code
+
+            #include <cds/algo/backoff_strategy.h>
+            namespace bkoff = cds::backoff;
+
+            struct ms5  ;   // tag to select 5ms
+            struct ms10 ;   // tag to select 10ms
+
+            // // define your back-off specialization
+            typedef bkoff::delay<std::chrono::milliseconds, ms5> delay5;
+            typedef bkoff::delay<std::chrono::milliseconds, ms10> delay10;
+
+            // // set up the timeouts
+            delay5::s_nTimeout = 5;
+            delay10::s_nTimeout = 10;
+            \endcode
+
+            Another way of solving this problem is subclassing \p delay back-off class:
+            \code
+            #include <cds/algo/backoff_strategy.h>
+            namespace bkoff = cds::backoff;
+            typedef bkoff::delay<> delay_bkoff;
+
+            class delay5: public delay_bkoff {
+            public:
+                delay5(): delay_bkoff( 5 ) {}
+            };
+
+            class delay10: public delay_bkoff {
+            public:
+                delay10(): delay_bkoff( 10 ) {}
+            };
+            \endcode
+
+        */
+        template <class Duration = cds_std::chrono::milliseconds, typename Tag=void >
+        class delay
+        {
+        public:
+            typedef Duration duration_type; ///< Duration type (default \p std::chrono::milliseconds)
+            static unsigned int s_nTimeout; ///< default timeout, =5
+
+        protected:
+            ///@cond
+            unsigned int const m_nTimeout;
+            ///@endcond
+
+        public:
+            /// Default ctor takes the timeout from s_nTimeout
+            delay()
+                : m_nTimeout( s_nTimeout )
+            {}
+
+            /// Initializes timeout from \p nTimeout
+            CDS_CONSTEXPR delay( unsigned int nTimeout )
+                : m_nTimeout( nTimeout )
+            {}
+
+            //@cond
+            void operator()() const
+            {
+                cds_std::this_thread::sleep_for( duration_type( m_nTimeout ));
+            }
+
+            template <typename Predicate>
+            bool operator()( Predicate pr ) const
+            {
+                for ( unsigned int i = 0; i < m_nTimeout; i += 2 ) {
+                    if ( pr() )
+                        return true;
+                    cds_std::this_thread::sleep_for( duration_type( 2 ));
+                }
+                return false;
+            }
+
+            void reset() const
+            {}
+            //@endcond
+        };
+
+        //@cond
+        template <class Duration, typename Tag>
+        unsigned int delay<Duration, Tag>::s_nTimeout = 5;
+        //@endcond
+
+
+        /// Delay back-off strategy, template version
+        /**
+            This is a template version of backoff::delay class.
+            Template parameter \p Timeout sets a delay timeout.
+            The declaration <tt>cds::backoff::delay_of< 5 > bkoff</tt> is equal for
+            <tt>cds::backoff::delay<> bkoff(5)</tt>.
+        */
+        template <unsigned int Timeout, class Duration = cds_std::chrono::milliseconds >
+        class delay_of: public delay<Duration>
+        {
+        //@cond
+            typedef delay<Duration> base_class;
+        public:
+            delay_of()
+                : base_class( Timeout )
+            {}
+        //@endcond
+        };
+
+
+        /// Default backoff strategy
+        typedef exponential<hint, yield>    Default;
+
+        /// Default back-off strategy for lock primitives
+        typedef exponential<hint, yield>    LockDefault;
+
+    } // namespace backoff
+} // namespace cds
+
+
+#endif // #ifndef __CDS_BACKOFF_STRATEGY_H
index d5b780b67db1be5aa0f44f4af600e2468e4d1f3e..4499dc031257e51a712469c4d48de28a130e5129 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <cds/cxx11_atomic.h>
 #include <cds/details/allocator.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/lock/spinlock.h>
 #include <cds/details/std/mutex.h>  // lock_guard
 #include <cds/opt/options.h>
diff --git a/cds/backoff_strategy.h b/cds/backoff_strategy.h
deleted file mode 100644 (file)
index b36df53..0000000
+++ /dev/null
@@ -1,426 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDS_BACKOFF_STRATEGY_H
-#define __CDS_BACKOFF_STRATEGY_H
-
-/*
-    Filename: backoff_strategy.h
-    Created 2007.03.01 by Maxim Khiszinsky
-
-    Description:
-         Generic back-off strategies
-
-    Editions:
-    2007.03.01  Maxim Khiszinsky    Created
-    2008.10.02  Maxim Khiszinsky    Backoff action transfers from contructor to operator() for all backoff schemas
-    2009.09.10  Maxim Khiszinsky    reset() function added
-*/
-
-#include <cds/compiler/backoff.h>
-#include <cds/details/std/thread.h>
-#include <cds/details/std/chrono.h>
-
-namespace cds {
-    /// Different backoff schemes
-    /**
-        Back-off schema may be used in lock-free algorithms when the algorithm cannot perform some action because a conflict
-        with the other concurrent operation is encountered. In this case current thread can do another work or can call
-        processor's performance hint.
-
-        The interface of back-off strategy is following:
-        \code
-            struct backoff_strategy {
-                void operator()();
-                template <typename Predicate> bool operator()( Predicate pr );
-                void reset();
-            };
-        \endcode
-
-        \p operator() operator calls back-off strategy's action. It is main part of back-off strategy.
-
-        Interruptible back-off <tt>template < typename Predicate > bool operator()( Predicate pr )</tt>
-        allows to interrupt back-off spinning if \p pr predicate returns \p true.
-        \p Predicate is a functor with the following interface:
-        \code
-        struct predicate {
-            bool operator()();
-        };
-        \endcode
-
-        \p reset() function resets internal state of back-off strategy to initial state. It is required for some
-        back-off strategies, for example, exponential back-off.
-    */
-    namespace backoff {
-
-        /// Empty backoff strategy. Do nothing
-        struct empty {
-            //@cond
-            void operator ()()
-            {}
-
-            template <typename Predicate>
-            bool operator()( Predicate pr )
-            {
-                return pr();
-            }
-
-            void reset()
-            {}
-            //@endcond
-        };
-
-        /// Switch to another thread (yield). Good for thread preemption architecture.
-        struct yield {
-            //@cond
-            void operator ()()
-            {
-                cds_std::this_thread::yield();
-                //OS::yield();
-            }
-
-            template <typename Predicate>
-            bool operator()( Predicate pr )
-            {
-                if ( pr() )
-                    return true;
-                operator()();
-                return false;
-            }
-
-            void reset()
-            {}
-            //@endcond
-        };
-
-        /// Random pause
-        /**
-            This back-off strategy calls processor-specific pause hint instruction
-            if one is available for the processor architecture.
-        */
-        struct pause {
-            //@cond
-            void operator ()()
-            {
-#            ifdef CDS_backoff_pause_defined
-                platform::backoff_pause();
-#            endif
-            }
-
-            template <typename Predicate>
-            bool operator()( Predicate pr )
-            {
-                if ( pr() )
-                    return true;
-                operator()();
-                return false;
-            }
-
-            void reset()
-            {}
-            //@endcond
-        };
-
-        /// Processor hint back-off
-        /**
-            This back-off schema calls performance hint instruction if it is available for current processor.
-            Otherwise, it calls \p nop.
-        */
-        struct hint
-        {
-        //@cond
-            void operator ()()
-            {
-#           if defined(CDS_backoff_hint_defined)
-                platform::backoff_hint();
-#           elif defined(CDS_backoff_nop_defined)
-                platform::backoff_nop();
-#           endif
-            }
-
-            template <typename Predicate>
-            bool operator()( Predicate pr )
-            {
-                if ( pr() )
-                    return true;
-                operator()();
-                return false;
-            }
-
-            void reset()
-            {}
-        //@endcond
-        };
-
-        /// Exponential back-off
-        /**
-            This back-off strategy is composite. It consists of \p SpinBkoff and \p YieldBkoff
-            back-off strategy. In first, the strategy tries to apply repeatedly \p SpinBkoff
-            (spinning phase) until internal counter of failed attempts reaches its maximum
-            spinning value. Then, the strategy transits to high-contention phase
-            where it applies \p YieldBkoff until \p reset() is called.
-            On each spinning iteration the internal spinning counter is doubled.
-
-            Choosing the best value for maximum spinning bound is platform and task specific.
-            In this implementation, the default values for maximum and minimum spinning is statically
-            declared so you can set its value globally for your platform.
-            The third template argument, \p Tag, is used to separate implementation. For
-            example, you may define two \p exponential back-offs that is the best for your task A and B:
-            \code
-
-            #include <cds/backoff_strategy.h>
-            namespace bkoff = cds::backoff;
-
-            struct tagA ;   // tag to select task A implementation
-            struct tagB ;   // tag to select task B implementation
-
-            // // define your back-off specialization
-            typedef bkoff::exponential<bkoff::hint, bkoff::yield, tagA> expBackOffA;
-            typedef bkoff::exponential<bkoff::hint, bkoff::yield, tagB> expBackOffB;
-
-            // // set up the best bounds for task A
-            expBackOffA::s_nExpMin = 32;
-            expBackOffA::s_nExpMax = 1024;
-
-            // // set up the best bounds for task B
-            expBackOffB::s_nExpMin = 2;
-            expBackOffB::s_nExpMax = 512;
-
-            \endcode
-
-            Another way of solving this problem is subclassing \p exponential back-off class:
-            \code
-            #include <cds/backoff_strategy.h>
-            namespace bkoff = cds::backoff;
-            typedef bkoff::exponential<bkoff::hint, bkoff::yield>   base_bkoff;
-
-            class expBackOffA: public base_bkoff
-            {
-            public:
-                expBackOffA()
-                    : base_bkoff( 32, 1024 )
-                    {}
-            };
-
-            class expBackOffB: public base_bkoff
-            {
-            public:
-                expBackOffB()
-                    : base_bkoff( 2, 512 )
-                    {}
-            };
-            \endcode
-        */
-        template <typename SpinBkoff, typename YieldBkoff, typename Tag=void>
-        class exponential
-        {
-        public:
-            typedef SpinBkoff  spin_backoff    ;   ///< spin back-off strategy
-            typedef YieldBkoff yield_backoff   ;   ///< yield back-off strategy
-            typedef Tag         impl_tag        ;   ///< implementation separation tag
-
-            static size_t s_nExpMin ;   ///< Default minimum spinning bound (16)
-            static size_t s_nExpMax ;   ///< Default maximum spinning bound (16384)
-
-        protected:
-            size_t  m_nExpCur   ;   ///< Current spinning
-            size_t  m_nExpMin   ;   ///< Minimum spinning bound
-            size_t  m_nExpMax   ;   ///< Maximum spinning bound
-
-            spin_backoff    m_bkSpin    ;   ///< Spinning (fast-path) phase back-off strategy
-            yield_backoff   m_bkYield   ;   ///< Yield phase back-off strategy
-
-        public:
-            /// Initializes m_nExpMin and m_nExpMax from default s_nExpMin and s_nExpMax respectively
-            exponential()
-                : m_nExpMin( s_nExpMin )
-                , m_nExpMax( s_nExpMax )
-            {
-                m_nExpCur = m_nExpMin;
-            }
-
-            /// Explicitly defined bounds of spinning
-            /**
-                The \p libcds library never calls this ctor.
-            */
-            exponential(
-                size_t nExpMin,     ///< Minimum spinning
-                size_t nExpMax      ///< Maximum spinning
-                )
-                : m_nExpMin( nExpMin )
-                , m_nExpMax( nExpMax )
-            {
-                m_nExpCur = m_nExpMin;
-            }
-
-            //@cond
-            void operator ()()
-            {
-                if ( m_nExpCur <= m_nExpMax ) {
-                    for ( size_t n = 0; n < m_nExpCur; ++n )
-                        m_bkSpin();
-                    m_nExpCur *= 2;
-                }
-                else
-                    m_bkYield();
-            }
-
-            template <typename Predicate>
-            bool operator()( Predicate pr )
-            {
-                if ( m_nExpCur <= m_nExpMax ) {
-                    for ( size_t n = 0; n < m_nExpCur; ++n ) {
-                        if ( m_bkSpin(pr) )
-                            return true;
-                    }
-                    m_nExpCur *= 2;
-                }
-                else
-                    return m_bkYield(pr);
-                return false;
-            }
-
-            void reset()
-            {
-                m_nExpCur = m_nExpMin;
-                m_bkSpin.reset();
-                m_bkYield.reset();
-            }
-            //@endcond
-        };
-
-        //@cond
-        template <typename SpinBkoff, typename YieldBkoff, typename Tag>
-        size_t exponential<SpinBkoff, YieldBkoff, Tag>::s_nExpMin = 16;
-
-        template <typename SpinBkoff, typename YieldBkoff, typename Tag>
-        size_t exponential<SpinBkoff, YieldBkoff, Tag>::s_nExpMax = 16 * 1024;
-        //@endcond
-
-        /// Delay back-off strategy
-        /**
-            Template arguments:
-            - \p Duration - duration type, default is \p std::chrono::milliseconds
-            - \p Tag - a selector tag
-
-            Choosing the best value for th timeout is platform and task specific.
-            In this implementation, the default values for timeout is statically
-            declared so you can set its value globally for your platform.
-            The second template argument, \p Tag, is used to separate implementation. For
-            example, you may define two \p delay back-offs for 5 and 10 ms timeout:
-            \code
-
-            #include <cds/backoff_strategy.h>
-            namespace bkoff = cds::backoff;
-
-            struct ms5  ;   // tag to select 5ms
-            struct ms10 ;   // tag to select 10ms
-
-            // // define your back-off specialization
-            typedef bkoff::delay<std::chrono::milliseconds, ms5> delay5;
-            typedef bkoff::delay<std::chrono::milliseconds, ms10> delay10;
-
-            // // set up the timeouts
-            delay5::s_nTimeout = 5;
-            delay10::s_nTimeout = 10;
-            \endcode
-
-            Another way of solving this problem is subclassing \p delay back-off class:
-            \code
-            #include <cds/backoff_strategy.h>
-            namespace bkoff = cds::backoff;
-            typedef bkoff::delay<> delay_bkoff;
-
-            class delay5: public delay_bkoff {
-            public:
-                delay5(): delay_bkoff( 5 ) {}
-            };
-
-            class delay10: public delay_bkoff {
-            public:
-                delay10(): delay_bkoff( 10 ) {}
-            };
-            \endcode
-
-        */
-        template <class Duration = cds_std::chrono::milliseconds, typename Tag=void >
-        class delay
-        {
-        public:
-            typedef Duration duration_type; ///< Duration type (default \p std::chrono::milliseconds)
-            static unsigned int s_nTimeout; ///< default timeout, =5
-
-        protected:
-            ///@cond
-            unsigned int const m_nTimeout;
-            ///@endcond
-
-        public:
-            /// Default ctor takes the timeout from s_nTimeout
-            delay()
-                : m_nTimeout( s_nTimeout )
-            {}
-
-            /// Initializes timeout from \p nTimeout
-            CDS_CONSTEXPR delay( unsigned int nTimeout )
-                : m_nTimeout( nTimeout )
-            {}
-
-            //@cond
-            void operator()() const
-            {
-                cds_std::this_thread::sleep_for( duration_type( m_nTimeout ));
-            }
-
-            template <typename Predicate>
-            bool operator()( Predicate pr ) const
-            {
-                for ( unsigned int i = 0; i < m_nTimeout; i += 2 ) {
-                    if ( pr() )
-                        return true;
-                    cds_std::this_thread::sleep_for( duration_type( 2 ));
-                }
-                return false;
-            }
-
-            void reset() const
-            {}
-            //@endcond
-        };
-
-        //@cond
-        template <class Duration, typename Tag>
-        unsigned int delay<Duration, Tag>::s_nTimeout = 5;
-        //@endcond
-
-
-        /// Delay back-off strategy, template version
-        /**
-            This is a template version of backoff::delay class.
-            Template parameter \p Timeout sets a delay timeout.
-            The declaration <tt>cds::backoff::delay_of< 5 > bkoff</tt> is equal for
-            <tt>cds::backoff::delay<> bkoff(5)</tt>.
-        */
-        template <unsigned int Timeout, class Duration = cds_std::chrono::milliseconds >
-        class delay_of: public delay<Duration>
-        {
-        //@cond
-            typedef delay<Duration> base_class;
-        public:
-            delay_of()
-                : base_class( Timeout )
-            {}
-        //@endcond
-        };
-
-
-        /// Default backoff strategy
-        typedef exponential<hint, yield>    Default;
-
-        /// Default back-off strategy for lock primitives
-        typedef exponential<hint, yield>    LockDefault;
-
-    } // namespace backoff
-} // namespace cds
-
-
-#endif // #ifndef __CDS_BACKOFF_STRATEGY_H
index 1247f4b8070cca64358e647593d342b7f73ca654..8fa8e4f6bdb4d96e13f19cfc78780c02262b9bd8 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <cds/intrusive/node_traits.h>
 #include <cds/details/allocator.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 
 namespace cds {
 
index 19be1a4fb7289e9f72c8e03529e2c64bc0a0e5fe..e12e964420bc3fde5a11701573f64f6011a714a9 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <cds/cxx11_atomic.h>
 #include <cds/os/thread.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/lock/scoped_lock.h>
 
 #include <cds/details/noncopyable.h>
index 5df1fcbc7f2d7bedd739e30024dd98c973f17a69..b5d85b49369a227d295b78edcf9becb9ab73a194 100644 (file)
@@ -4,7 +4,7 @@
 #define _CDS_URCU_DETAILS_GPB_H
 
 #include <cds/urcu/details/gp.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/container/vyukov_mpmc_cycle_queue.h>
 
 #include <cds/details/std/mutex.h>
index 4d9a852da8a54948ebd36ffa2c1ecb1200a47931..2ab6553f8a32390fccc4aa3771bfbff8f413a7b0 100644 (file)
@@ -4,7 +4,7 @@
 #define _CDS_URCU_DETAILS_GPI_H
 
 #include <cds/urcu/details/gp.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/lock/scoped_lock.h>
 
 #include <cds/details/std/mutex.h>
index c741ea2e837796bb6578a7a6c94c1fda0bed50b8..994e50a64ce114a5157d905d4e8d96f68f51a458 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <cds/urcu/details/gp.h>
 #include <cds/urcu/dispose_thread.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/container/vyukov_mpmc_cycle_queue.h>
 
 namespace cds { namespace urcu {
index 81f8801350bb70f58f5904de872520873b46ecf4..5ab1ad255e3269e0238ab238babe65ee24b9e215 100644 (file)
@@ -6,7 +6,7 @@
 #include <cds/urcu/details/sh.h>
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
 
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/container/vyukov_mpmc_cycle_queue.h>
 
 #include <cds/details/std/mutex.h>
index e482094339ad983239e9002f36121e025bd79815..9056e89443e1d20a9d59189f26c2f088223b3fa8 100644 (file)
@@ -7,7 +7,7 @@
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
 
 #include <cds/urcu/dispose_thread.h>
-#include <cds/backoff_strategy.h>
+#include <cds/algo/backoff_strategy.h>
 #include <cds/container/vyukov_mpmc_cycle_queue.h>
 
 namespace cds { namespace urcu {
index 3c1619c12a2fceebc5720e43841be0d4b1e29ab9..5a8686fbd6b01d463e26e3abbcf827f034841cca 100644 (file)
@@ -3,7 +3,6 @@
 #ifndef _CDS_URCU_DISPOSE_THREAD_H
 #define _CDS_URCU_DISPOSE_THREAD_H
 
-//#include <cds/backoff_strategy.h>
 #include <cds/details/std/thread.h>
 #include <cds/details/std/mutex.h>
 #include <cds/details/std/condition_variable.h>
index ed9e83be3445e32c965ce031206c3cad56ad7003..2c7c36048b9c2a8569cd21cbe08806bb782d84ae 100644 (file)
     <ClCompile Include="..\..\..\src\urcu_sh.cpp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <ClInclude Include="..\..\..\cds\algo\backoff_strategy.h" />\r
     <ClInclude Include="..\..\..\cds\algo\base.h" />\r
     <ClInclude Include="..\..\..\cds\algo\elimination.h" />\r
     <ClInclude Include="..\..\..\cds\algo\elimination_opt.h" />\r
     <ClInclude Include="..\..\..\cds\urcu\signal_buffered.h" />\r
     <ClInclude Include="..\..\..\cds\urcu\signal_threaded.h" />\r
     <ClInclude Include="..\..\..\src\hzp_const.h" />\r
-    <ClInclude Include="..\..\..\cds\backoff_strategy.h" />\r
     <ClInclude Include="..\..\..\cds\bitop.h" />\r
     <ClInclude Include="..\..\..\cds\init.h" />\r
     <ClInclude Include="..\..\..\cds\int_algo.h" />\r
index 5df3e4978ebefb709b9a41a1cb20c8dc5a0b11d4..7ac92ccffff47de96b0ddce2ba169315ba3aca75 100644 (file)
     <ClInclude Include="..\..\..\src\hzp_const.h">\r
       <Filter>Source Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\cds\backoff_strategy.h">\r
-      <Filter>Header Files\cds</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\cds\bitop.h">\r
       <Filter>Header Files\cds</Filter>\r
     </ClInclude>\r
     <ClInclude Include="..\..\..\cds\algo\flat_combining.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\cds\algo\backoff_strategy.h">\r
+      <Filter>Header Files\cds\algo</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file