X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Fstress%2Fqueue%2Fpush_pop.cpp;h=20a3d39c78b5656a5ad76d8b7fc992bd30e984c2;hb=f6a4db0477151d641ac2a89aa79cf537b620e154;hp=f34e5a985111f753071cf777d1fa82b3445a10e5;hpb=517704cabbd9aff142b5b2fd5e08837c682ea5be;p=libcds.git diff --git a/test/stress/queue/push_pop.cpp b/test/stress/queue/push_pop.cpp index f34e5a98..20a3d39c 100644 --- a/test/stress/queue/push_pop.cpp +++ b/test/stress/queue/push_pop.cpp @@ -5,7 +5,7 @@ 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: @@ -42,16 +42,19 @@ namespace { static std::atomic s_nProducerDone( 0 ); + struct old_value + { + size_t nNo; + size_t nWriterNo; + }; + + template class queue_push_pop: public cds_test::stress_fixture { protected: - struct value_type - { - size_t nNo; - size_t nWriterNo; - }; + using value_type = Value; - enum { + enum { producer_thread, consumer_thread }; @@ -167,7 +170,7 @@ namespace { const size_t nTotalWriters = s_nProducerThreadCount; value_type v; while ( true ) { - if ( m_Queue.pop( v ) ) { + if ( m_Queue.pop( v )) { ++m_nPopped; if ( v.nWriterNo < nTotalWriters ) m_WriterData[ v.nWriterNo ].push_back( v.nNo ); @@ -178,7 +181,7 @@ namespace { ++m_nPopEmpty; if ( s_nProducerDone.load() >= nTotalWriters ) { - if ( m_Queue.empty() ) + if ( m_Queue.empty()) break; } } @@ -219,7 +222,7 @@ namespace { nTotalPops += consumer.m_nPopped; nPopFalse += consumer.m_nPopEmpty; arrConsumer.push_back( &consumer ); - EXPECT_EQ( consumer.m_nBadWriter, 0 ) << "consumer_thread_no " << i; + EXPECT_EQ( consumer.m_nBadWriter, 0u ) << "consumer_thread_no " << i; size_t nPopped = 0; for ( size_t n = 0; n < s_nProducerThreadCount; ++n ) @@ -232,13 +235,13 @@ namespace { Producer& producer = static_cast( thr ); nPushFailed += producer.m_nPushFailed; - EXPECT_EQ( producer.m_nPushFailed, 0 ) << "producer_thread_no " << i; + EXPECT_EQ( producer.m_nPushFailed, 0u ) << "producer_thread_no " << i; } } EXPECT_EQ( nTotalPops, nPoppedItems ); EXPECT_EQ( nTotalPops + nPostTestPops, s_nQueueSize ) << "nTotalPops=" << nTotalPops << ", nPostTestPops=" << nPostTestPops; - EXPECT_TRUE( q.empty() ); + EXPECT_TRUE( q.empty()); // Test consistency of popped sequence for ( size_t nWriter = 0; nWriter < s_nProducerThreadCount; ++nWriter ) { @@ -259,12 +262,12 @@ namespace { arrData.push_back( *it ); } - std::sort( arrData.begin(), arrData.end() ); + std::sort( arrData.begin(), arrData.end()); for ( size_t i=1; i < arrData.size(); ++i ) { EXPECT_EQ( arrData[i - 1] + 1, arrData[i] ) << "producer=" << nWriter; } - EXPECT_EQ( arrData[0], 0 ) << "producer=" << nWriter; + EXPECT_EQ( arrData[0], 0u ) << "producer=" << nWriter; EXPECT_EQ( arrData[arrData.size() - 1], m_nThreadPushCount - 1 ) << "producer=" << nWriter; } } @@ -299,33 +302,37 @@ namespace { } public: - static void SetUpTestCase() - { - cds_test::config const& cfg = get_config( "queue_push_pop" ); - + static void SetUpTestCase() + { + cds_test::config const& cfg = get_config( "queue_push_pop" ); + s_nConsumerThreadCount = cfg.get_size_t( "ConsumerCount", s_nConsumerThreadCount ); s_nProducerThreadCount = cfg.get_size_t( "ProducerCount", s_nProducerThreadCount ); s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize ); - if ( s_nConsumerThreadCount == 0 ) + if ( s_nConsumerThreadCount == 0u ) s_nConsumerThreadCount = 1; - if ( s_nProducerThreadCount == 0 ) + if ( s_nProducerThreadCount == 0u ) s_nProducerThreadCount = 1; - if ( s_nQueueSize == 0 ) + if ( s_nQueueSize == 0u ) s_nQueueSize = 1000; - } - - //static void TearDownTestCase(); + } + + //static void TearDownTestCase(); }; - CDSSTRESS_MSQueue( queue_push_pop ) - CDSSTRESS_MoirQueue( queue_push_pop ) - CDSSTRESS_BasketQueue( queue_push_pop ) - CDSSTRESS_OptimsticQueue( queue_push_pop ) - CDSSTRESS_FCQueue( queue_push_pop ) - CDSSTRESS_FCDeque( queue_push_pop ) - CDSSTRESS_RWQueue( queue_push_pop ) - CDSSTRESS_StdQueue( queue_push_pop ) + using value_for_fc_with_heavy_value = queue_push_pop< HeavyValue<36000> >; + using old_queue_push_pop = queue_push_pop<>; + +// CDSSTRESS_MSQueue( old_queue_push_pop ) +// CDSSTRESS_MoirQueue( old_queue_push_pop ) +// CDSSTRESS_BasketQueue( old_queue_push_pop ) +// CDSSTRESS_OptimsticQueue( old_queue_push_pop ) +// CDSSTRESS_FCQueue( old_queue_push_pop ) +// CDSSTRESS_FCDeque( old_queue_push_pop ) + CDSSTRESS_FCDeque_HeavyValue( value_for_fc_with_heavy_value ) +// CDSSTRESS_RWQueue( old_queue_push_pop ) +// CDSSTRESS_StdQueue( old_queue_push_pop ) #undef CDSSTRESS_Queue_F #define CDSSTRESS_Queue_F( test_fixture, type_name, level ) \ @@ -337,8 +344,7 @@ namespace { test( queue ); \ } - CDSSTRESS_TsigasQueue( queue_push_pop ) - CDSSTRESS_VyukovQueue( queue_push_pop ) + CDSSTRESS_VyukovQueue( old_queue_push_pop ) #undef CDSSTRESS_Queue_F @@ -347,10 +353,10 @@ namespace { // SegmentedQueue test class segmented_queue_push_pop - : public queue_push_pop + : public queue_push_pop<> , public ::testing::WithParamInterface< size_t > { - typedef queue_push_pop base_class; + typedef queue_push_pop<> base_class; protected: @@ -397,7 +403,7 @@ namespace { test< queue_type >(); \ } - CDSSTRESS_SegmentedQueue( segmented_queue_push_pop ) +// CDSSTRESS_SegmentedQueue( segmented_queue_push_pop ) INSTANTIATE_TEST_CASE_P( SQ, segmented_queue_push_pop,