@@ -148,9 +148,9 @@ TEST(ChannelTest, Iterator)
148148
149149TEST (ChannelTest, Multithreading)
150150{
151- const int numbers = 1000 ;
152- const std::int64_t expected = 500500 ;
153- constexpr std::size_t kThreadsToReadFrom = 50 ;
151+ const int numbers = 10000 ;
152+ const std::int64_t expected = 50005000 ;
153+ constexpr std::size_t kThreadsToReadFrom = 100 ;
154154
155155 msd::channel<int > channel{10 };
156156
@@ -176,8 +176,6 @@ TEST(ChannelTest, Multithreading)
176176
177177 sum_numbers += out;
178178 ++count_numbers;
179-
180- std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
181179 }
182180 --wait_counter;
183181 cond_wait.notify_one ();
@@ -188,19 +186,16 @@ TEST(ChannelTest, Multithreading)
188186 threads.emplace_back (std::thread{worker});
189187 }
190188
191- auto sender = [&] {
192- // Send numbers to channel
193- for (int i = 1 ; i <= numbers; ++i) {
194- channel << i;
189+ // Send numbers to channel
190+ for (int i = 1 ; i <= numbers; ++i) {
191+ channel << i;
195192
196- // Notify threads than then can start reading
197- if (!ready_to_read) {
198- ready_to_read = true ;
199- cond_read.notify_all ();
200- }
193+ // Notify threads than then can start reading
194+ if (!ready_to_read) {
195+ ready_to_read = true ;
196+ cond_read.notify_all ();
201197 }
202- };
203- threads.emplace_back (std::thread{sender});
198+ }
204199
205200 // Wait until all items have been read
206201 std::unique_lock<std::mutex> lock{mtx_wait};
0 commit comments