From d65789613576cd85319f75d0fe83a42201b55bbc Mon Sep 17 00:00:00 2001 From: khizmax Date: Wed, 26 Nov 2014 19:39:07 +0300 Subject: [PATCH] back-off strategies: use std::declval in noexcept specifications --- cds/algo/backoff_strategy.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cds/algo/backoff_strategy.h b/cds/algo/backoff_strategy.h index c80ea829..75f43e34 100644 --- a/cds/algo/backoff_strategy.h +++ b/cds/algo/backoff_strategy.h @@ -16,6 +16,7 @@ 2009.09.10 Maxim Khiszinsky reset() function added */ +#include // declval #include #include #include @@ -59,7 +60,7 @@ namespace cds { {} template - bool operator()(Predicate pr) CDS_NOEXCEPT + bool operator()(Predicate pr) CDS_NOEXCEPT_( noexcept(std::declval()() )) { return pr(); } @@ -78,7 +79,7 @@ namespace cds { } template - bool operator()( Predicate pr ) CDS_NOEXCEPT + bool operator()(Predicate pr) CDS_NOEXCEPT_( noexcept(std::declval()() )) { if ( pr() ) return true; @@ -106,7 +107,7 @@ namespace cds { } template - bool operator()( Predicate pr ) CDS_NOEXCEPT + bool operator()(Predicate pr) CDS_NOEXCEPT_( noexcept(std::declval()() )) { if ( pr() ) return true; @@ -137,7 +138,7 @@ namespace cds { } template - bool operator()( Predicate pr ) CDS_NOEXCEPT + bool operator()(Predicate pr) CDS_NOEXCEPT_(noexcept(std::declval()() )) { if ( pr() ) return true; @@ -252,7 +253,7 @@ namespace cds { } //@cond - void operator ()() CDS_NOEXCEPT_(noexcept(spin_backoff()()) && noexcept(yield_backoff()())) + void operator ()() CDS_NOEXCEPT_(noexcept(std::declval()()) && noexcept(std::declval()())) { if ( m_nExpCur <= m_nExpMax ) { for ( size_t n = 0; n < m_nExpCur; ++n ) @@ -264,7 +265,7 @@ namespace cds { } template - bool operator()( Predicate pr ) CDS_NOEXCEPT_(noexcept( spin_backoff()()) && noexcept( yield_backoff()())) + bool operator()( Predicate pr ) CDS_NOEXCEPT_( noexcept(std::declval()()) && noexcept(std::declval()()) && noexcept(std::declval()() )) { if ( m_nExpCur <= m_nExpMax ) { for ( size_t n = 0; n < m_nExpCur; ++n ) { @@ -278,7 +279,7 @@ namespace cds { return false; } - void reset() CDS_NOEXCEPT_(noexcept(spin_backoff().reset()) && noexcept(yield_backoff().reset())) + void reset() CDS_NOEXCEPT_( noexcept( std::declval().reset() ) && noexcept( std::declval().reset() )) { m_nExpCur = m_nExpMin; m_bkSpin.reset(); @@ -365,13 +366,13 @@ namespace cds { {} //@cond - void operator()() const CDS_NOEXCEPT + void operator()() const { std::this_thread::sleep_for( duration_type( m_nTimeout )); } template - bool operator()( Predicate pr ) const CDS_NOEXCEPT + bool operator()(Predicate pr) const { for ( unsigned int i = 0; i < m_nTimeout; i += 2 ) { if ( pr() ) -- 2.34.1