From 239d8e6b0abbff4917f329bc8ba277c7972957d2 Mon Sep 17 00:00:00 2001 From: khizmax Date: Thu, 25 Sep 2014 22:55:53 +0400 Subject: [PATCH] Remove hash_functor_selector.h, use only std::hash Fix return value in intrusive MSPriorityQueue::pop() --- cds/details/hash_functor_selector.h | 51 --------------------------- cds/intrusive/mspriority_queue.h | 2 +- cds/opt/hash.h | 15 +++----- projects/Win/vc12/cds.vcxproj | 1 - projects/Win/vc12/cds.vcxproj.filters | 3 -- src/ptb_gc.cpp | 8 ++--- tests/unit/map2/map_delodd.cpp | 39 +++++++++----------- tests/unit/set2/set_delodd.cpp | 18 +++++----- 8 files changed, 35 insertions(+), 102 deletions(-) delete mode 100644 cds/details/hash_functor_selector.h diff --git a/cds/details/hash_functor_selector.h b/cds/details/hash_functor_selector.h deleted file mode 100644 index c7a49d4e..00000000 --- a/cds/details/hash_functor_selector.h +++ /dev/null @@ -1,51 +0,0 @@ -//$$CDS-header$$ - -#ifndef __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H -#define __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H - -//@cond - -#if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL -# include -#elif CDS_COMPILER == CDS_COMPILER_GCC || CDS_COMPILER == CDS_COMPILER_CLANG - // GCC 4.3+ -# include -#else - // Default, use boost implementation -# include -#endif - -namespace cds { namespace details { - -#if CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL -# if _MSC_VER >= 1600 - // MSVC 2010 and above - using std::hash; -# define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { -# define CDS_END_STD_HASH_NAMESPACE } -# define CDS_STD_HASH_NAMESPACE std -# else - // MSVC 2008 - using std::tr1::hash; -# define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { namespace tr1 { -# define CDS_END_STD_HASH_NAMESPACE }} -# define CDS_STD_HASH_NAMESPACE std::tr1 -# endif -#elif CDS_COMPILER == CDS_COMPILER_GCC || CDS_COMPILER == CDS_COMPILER_CLANG - // GCC 4.3+ - using std::hash; -# define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { -# define CDS_END_STD_HASH_NAMESPACE } -# define CDS_STD_HASH_NAMESPACE std -#else - // Default, use boost implementation - using std::tr1::hash; -# define CDS_BEGIN_STD_HASH_NAMESPACE namespace std { namespace tr1 { -# define CDS_END_STD_HASH_NAMESPACE }} -# define CDS_STD_HASH_NAMESPACE std::tr1 -#endif - -}} // namespace cds::details -//@endcond - -#endif // __CDS_DETAILS_HASH_FUNCTOR_SELECTOR_H diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index d0a8d854..bd94dab3 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -286,7 +286,7 @@ namespace cds { namespace intrusive { // the heap is empty m_Lock.unlock(); m_Stat.onPopFailed(); - return false; + return nullptr; } counter_type nBottom = m_ItemCounter.reversed_value(); m_ItemCounter.dec(); diff --git a/cds/opt/hash.h b/cds/opt/hash.h index 18fe4bbb..bd407195 100644 --- a/cds/opt/hash.h +++ b/cds/opt/hash.h @@ -4,8 +4,8 @@ #define __CDS_OPT_HASH_H #include +#include #include -#include namespace cds { namespace opt { @@ -36,10 +36,9 @@ namespace cds { namespace opt { /** The metafunction selects appropriate hash functor implementation. If \p Hash is not equal to opt::none, then result of metafunction is \p Hash. - Otherwise, the result is std::hash or boost::hash - depending of compiler you use. + Otherwise, the result is std::hash . - Note that default hash function like std::hash or boost::hash + Note that default hash function like std::hash is generally not suitable for complex type \p Q and its derivatives. You should manually provide particular hash functor for such types. */ @@ -56,7 +55,7 @@ namespace cds { namespace opt { template size_t operator()( Q const& key ) const { - return hash()( key ); + return std::hash()( key ); } }; }; @@ -107,19 +106,13 @@ namespace cds { namespace opt { //@cond // At least, two functors must be provided. Single functor is not supported -//#if CDS_COMPILER != CDS_COMPILER_INTEL - // Intel C++ compiler does not support template struct hash< std::tuple >; -//#endif //@endcond /// Multi-functor hash option setter - specialization for std::tuple template struct hash< std::tuple > { -//# if CDS_COMPILER == CDS_COMPILER_INTEL - //static_assert( sizeof...(Functors) > 1, "At least, two functors must be provided. Single functor is not supported" ); -//# endif //@cond template struct pack: public Base { diff --git a/projects/Win/vc12/cds.vcxproj b/projects/Win/vc12/cds.vcxproj index 9412ebc6..6721fb07 100644 --- a/projects/Win/vc12/cds.vcxproj +++ b/projects/Win/vc12/cds.vcxproj @@ -720,7 +720,6 @@ - diff --git a/projects/Win/vc12/cds.vcxproj.filters b/projects/Win/vc12/cds.vcxproj.filters index b5de3f4b..2d319256 100644 --- a/projects/Win/vc12/cds.vcxproj.filters +++ b/projects/Win/vc12/cds.vcxproj.filters @@ -830,9 +830,6 @@ Header Files\cds\details - - Header Files\cds\details - Header Files\cds\gc diff --git a/src/ptb_gc.cpp b/src/ptb_gc.cpp index 23016498..59a149c2 100644 --- a/src/ptb_gc.cpp +++ b/src/ptb_gc.cpp @@ -2,12 +2,12 @@ // Pass The Buck (PTB) Memory manager implementation +#include // std::fill +#include // std::hash + #include #include -#include -#include // std::fill - namespace cds { namespace gc { namespace ptb { namespace details { @@ -25,7 +25,7 @@ namespace cds { namespace gc { namespace ptb { } item_type& bucket( guard_data::guarded_ptr p ) { - return m_Buckets[ cds::details::hash()( p ) & (m_nBucketCount - 1) ]; + return m_Buckets[ std::hash()( p ) & (m_nBucketCount - 1) ]; } public: diff --git a/tests/unit/map2/map_delodd.cpp b/tests/unit/map2/map_delodd.cpp index 6a8e3a48..a63abd32 100644 --- a/tests/unit/map2/map_delodd.cpp +++ b/tests/unit/map2/map_delodd.cpp @@ -83,32 +83,26 @@ namespace std { return false; } }; -} // namespace std - -CDS_BEGIN_STD_HASH_NAMESPACE -template <> -struct hash -{ - typedef size_t result_type; - typedef map2::key_thread argument_type; - size_t operator()(map2::key_thread const& k) const - { - return CDS_STD_HASH_NAMESPACE::hash()( k.nKey ); - } - size_t operator()(size_t k) const + template <> + struct hash { - return CDS_STD_HASH_NAMESPACE::hash()( k ); - } -}; -CDS_END_STD_HASH_NAMESPACE + typedef size_t result_type; + typedef map2::key_thread argument_type; -namespace boost { - inline size_t hash_value( map2::key_thread const& k ) - { - return CDS_STD_HASH_NAMESPACE::hash()( k.nKey ); - } + size_t operator()( map2::key_thread const& k ) const + { + return std::hash()(k.nKey); + } + size_t operator()( size_t k ) const + { + return std::hash()(k); + } + }; +} // namespace std +/* +namespace boost { template <> struct hash { @@ -125,6 +119,7 @@ namespace boost { } }; } // namespace boost +*/ namespace map2 { diff --git a/tests/unit/set2/set_delodd.cpp b/tests/unit/set2/set_delodd.cpp index d5dab928..d2604c80 100644 --- a/tests/unit/set2/set_delodd.cpp +++ b/tests/unit/set2/set_delodd.cpp @@ -83,30 +83,30 @@ namespace std { return false; } }; -} // namespace std -CDS_BEGIN_STD_HASH_NAMESPACE template <> struct hash { typedef size_t result_type; typedef set2::key_thread argument_type; - size_t operator()(set2::key_thread const& k) const + size_t operator()( set2::key_thread const& k ) const { - return CDS_STD_HASH_NAMESPACE::hash()( k.nKey ); + return std::hash()(k.nKey); } - size_t operator()(size_t k) const + size_t operator()( size_t k ) const { - return CDS_STD_HASH_NAMESPACE::hash()( k ); + return std::hash()(k); } }; -CDS_END_STD_HASH_NAMESPACE +} // namespace std + +/* namespace boost { inline size_t hash_value( set2::key_thread const& k ) { - return CDS_STD_HASH_NAMESPACE::hash()( k.nKey ); + return std::hash()( k.nKey ); } template <> @@ -125,7 +125,7 @@ namespace boost { } }; } // namespace boost - +*/ namespace set2 { -- 2.34.1