File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -349,12 +349,14 @@ class ConcurrentQueueTests : public TestClass<ConcurrentQueueTests>
349349 REGISTER_TEST (index_wrapping);
350350 REGISTER_TEST (subqueue_size_limit);
351351 REGISTER_TEST (exceptions);
352+ REGISTER_TEST (implicit_producer_churn);
352353 REGISTER_TEST (test_threaded);
353354 REGISTER_TEST (test_threaded_bulk);
354355 REGISTER_TEST (full_api<ConcurrentQueueDefaultTraits>);
355356 REGISTER_TEST (full_api<SmallIndexTraits>);
356357 REGISTER_TEST (blocking_wrappers);
357358 REGISTER_TEST (timed_blocking_wrappers);
359+
358360 // c_api/concurrentqueue
359361 REGISTER_TEST (c_api_create);
360362 REGISTER_TEST (c_api_enqueue);
@@ -3078,6 +3080,29 @@ class ConcurrentQueueTests : public TestClass<ConcurrentQueueTests>
30783080
30793081 return true ;
30803082 }
3083+
3084+ bool implicit_producer_churn ()
3085+ {
3086+ typedef TestTraits<4 > Traits;
3087+
3088+ for (int i = 0 ; i != 256 ; ++i) {
3089+ std::vector<SimpleThread> threads (32 );
3090+ ConcurrentQueue<int , Traits> q;
3091+ for (auto & thread : threads) {
3092+ SimpleThread t ([&] {
3093+ int x;
3094+ for (int j = 0 ; j != 16 ; ++j) {
3095+ q.enqueue (0 );
3096+ q.try_dequeue (x);
3097+ }
3098+ });
3099+ }
3100+ for (auto & thread : threads) {
3101+ thread.join ();
3102+ }
3103+ }
3104+ return true ;
3105+ }
30813106
30823107 bool test_threaded ()
30833108 {
You can’t perform that action at this time.
0 commit comments