@@ -113,7 +113,7 @@ template <typename T, typename Q>
113113void read_func (Q& wq, test_set<T>& s, std::mutex& mut) {
114114 while (true ) {
115115 std::optional<set_elem<T> > opt_elem = wq.wait_and_pop ();
116- if (!opt_elem) { // empty element means close has been called
116+ if (!opt_elem) { // empty element means request stop has been called
117117 return ;
118118 }
119119 std::lock_guard<std::mutex> lk (mut);
@@ -157,12 +157,12 @@ bool threaded_test(Q& wq, int num_readers, int num_writers, int slice, const T&
157157 std::this_thread::sleep_for (std::chrono::seconds (1 ));
158158 std::lock_guard<std::mutex> lk (mut);
159159 if (s.size () == tot) {
160+ wq.request_stop (); // tell the readers it's done
160161 done = true ;
161162 }
162163 }
163- wq.request_stop ();
164164
165- // join readers; since wait queue is closed they should all join immediately
165+ // join readers; since wait queue is stopped they should all join immediately
166166 for (auto & thr : rd_thrs) {
167167 thr.join ();
168168 }
@@ -338,7 +338,7 @@ std::size_t vv_pop_func(vv_wq& wq, std::size_t exp) {
338338 std::size_t n { 0u };
339339 while (n < exp) {
340340 auto res = wq.wait_and_pop ();
341- if (!res) { // queue has been closed
341+ if (!res) { // queue has been stopped
342342 break ;
343343 }
344344 REQUIRE (*res == data1);
@@ -413,7 +413,6 @@ SCENARIO ( "Threaded wait queue, deque int",
413413 REQUIRE ( threaded_test (wq, 1 , 1 , 100 , 44 ) );
414414
415415 // Parameters are 5 reader, 3 writer threads, 1000 slice
416- // threads will be created and joined
417416 REQUIRE ( threaded_test (wq, 5 , 3 , 1000 , 1212 ) );
418417 // Parameters are 60 reader, 40 writer threads, 5000 slice
419418 REQUIRE ( threaded_test (wq, 60 , 40 , 5000 , 5656 ) );
0 commit comments