* Run a bunch of threads to all call util::ThreadRename. * * @return the set of name each thread has after attempted renaming. */
| 27 | * @return the set of name each thread has after attempted renaming. |
| 28 | */ |
| 29 | std::set<std::string> RenameEnMasse(int num_threads) |
| 30 | { |
| 31 | std::vector<std::thread> threads; |
| 32 | std::set<std::string> names; |
| 33 | std::mutex lock; |
| 34 | |
| 35 | auto RenameThisThread = [&](int i) { |
| 36 | util::ThreadRename(TEST_THREAD_NAME_BASE + ToString(i)); |
| 37 | std::lock_guard<std::mutex> guard(lock); |
| 38 | names.insert(util::ThreadGetInternalName()); |
| 39 | }; |
| 40 | |
| 41 | for (int i = 0; i < num_threads; ++i) { |
| 42 | threads.push_back(std::thread(RenameThisThread, i)); |
| 43 | } |
| 44 | |
| 45 | for (std::thread& thread : threads) thread.join(); |
| 46 | |
| 47 | return names; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Rename a bunch of threads with the same basename (expect_multiple=true), ensuring suffixes are |
no test coverage detected