From ae9e00064648a3219b379acb2037a3ae3969c91d Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 29 Jul 2016 11:32:15 +0300 Subject: [PATCH] Precizing buffer type for MSPriorityQueue --- cds/intrusive/mspriority_queue.h | 2 +- cds/opt/buffer.h | 14 ++++++++------ test/stress/pqueue/pop.cpp | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index 2dda9d37..e3d211ef 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -240,7 +240,7 @@ namespace cds { namespace intrusive { //@endcond public: - typedef typename traits::buffer::template rebind::other buffer_type ; ///< Heap array buffer type + typedef typename traits::buffer::template rebind::other buffer_type ; ///< Heap array buffer type //@cond typedef cds::bitop::bit_reverse_counter<> item_counter_type; diff --git a/cds/opt/buffer.h b/cds/opt/buffer.h index 76dc4cf1..c54d1d5d 100644 --- a/cds/opt/buffer.h +++ b/cds/opt/buffer.h @@ -286,17 +286,18 @@ namespace cds { namespace opt { class uninitialized_dynamic_buffer { public: - typedef T value_type; ///< Value type + typedef T value_type; ///< Value type + typedef Alloc allocator; ///< Allocator type; static CDS_CONSTEXPR const bool c_bExp2 = Exp2; ///< \p Exp2 flag /// Rebind buffer for other template parameters - template + template struct rebind { typedef uninitialized_dynamic_buffer other; ///< Rebinding result type }; //@cond - typedef typename Alloc::template rebind::other allocator_type; + typedef typename allocator::template rebind::other allocator_type; //@endcond private: @@ -387,17 +388,18 @@ namespace cds { namespace opt { class initialized_dynamic_buffer { public: - typedef T value_type; ///< Value type + typedef T value_type; ///< Value type + typedef Alloc allocator; ///< Allocator type static CDS_CONSTEXPR const bool c_bExp2 = Exp2; ///< \p Exp2 flag /// Rebind buffer for other template parameters - template + template struct rebind { typedef initialized_dynamic_buffer other; ///< Rebinding result type }; //@cond - typedef cds::details::Allocator allocator_type; + typedef cds::details::Allocator allocator_type; //@endcond private: diff --git a/test/stress/pqueue/pop.cpp b/test/stress/pqueue/pop.cpp index 8127b0b9..75704ed7 100644 --- a/test/stress/pqueue/pop.cpp +++ b/test/stress/pqueue/pop.cpp @@ -70,6 +70,7 @@ namespace { ++m_nPopSuccess; nPrevKey = val.key; + /* while ( !m_Queue.empty() ) { if ( m_Queue.pop( val )) { ++m_nPopSuccess; @@ -86,6 +87,21 @@ namespace { else ++m_nPopFailed; } + */ + + while ( m_Queue.pop( val )) { + ++m_nPopSuccess; + if ( val.key > nPrevKey ) { + ++m_nPopError; + m_arrFailedPops.emplace_back( failed_pops{ nPrevKey, val.key } ); + } + else if ( val.key == nPrevKey ) { + ++m_nPopErrorEq; + m_arrFailedPops.emplace_back( failed_pops{ nPrevKey, val.key } ); + } + nPrevKey = val.key; + } + } else ++m_nPopFailed; -- 2.34.1