| 524 | } |
| 525 | |
| 526 | void DoSpawnAddsThreaded(ThreadPool* pool, int nthreads, int nadds, |
| 527 | AddTaskFunc add_func, |
| 528 | StopToken stop_token = StopToken::Unstoppable(), |
| 529 | StopSource* stop_source = nullptr) { |
| 530 | // Same as SpawnAdds, but do the task spawning from multiple threads |
| 531 | std::vector<AddTester> add_testers; |
| 532 | std::vector<std::thread> threads; |
| 533 | for (int i = 0; i < nthreads; ++i) { |
| 534 | add_testers.emplace_back(nadds, stop_token); |
| 535 | } |
| 536 | for (auto& add_tester : add_testers) { |
| 537 | threads.emplace_back([&] { add_tester.SpawnTasks(pool, add_func); }); |
| 538 | } |
| 539 | if (stop_source) { |
| 540 | stop_source->RequestStop(); |
| 541 | } |
| 542 | for (auto& thread : threads) { |
| 543 | thread.join(); |
| 544 | } |
| 545 | ASSERT_OK(pool->Shutdown()); |
| 546 | for (auto& add_tester : add_testers) { |
| 547 | if (stop_source) { |
| 548 | add_tester.CheckNotAllComputed(); |
| 549 | } else { |
| 550 | add_tester.CheckResults(); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | void SpawnAddsThreaded(ThreadPool* pool, int nthreads, int nadds, AddTaskFunc add_func, |
| 556 | StopToken stop_token = StopToken::Unstoppable()) { |
nothing calls this directly
no test coverage detected