File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ auto linear_insertions() {
2424 std::atomic<size_t > sum {0 };
2525
2626 std::function<void (int )> insert;
27- std::promise<void > promise;
27+ std::promise<int > promise;
2828 auto future = promise.get_future ();
2929
3030 insert = [&threadpool, &insert, &sum, &promise] (int i) {
@@ -35,7 +35,7 @@ auto linear_insertions() {
3535 }
3636 else {
3737 if (auto s = ++sum; s == threadpool.num_workers ()) {
38- promise.set_value ();
38+ promise.set_value (1 );
3939 }
4040 }
4141 };
@@ -45,7 +45,10 @@ auto linear_insertions() {
4545 }
4646
4747 // synchronize until all tasks finish
48- future.get ();
48+ threadpool.wait_for_all ();
49+
50+ assert (future.wait_for (std::chrono::seconds (0 )) == std::future_status::ready);
51+ assert (future.get () == 1 );
4952 assert (sum == num_threads);
5053
5154 auto end = std::chrono::high_resolution_clock::now ();
You can’t perform that action at this time.
0 commit comments