MCPcopy Create free account
hub / github.com/ElementsProject/elements / RenameEnMasse

Function RenameEnMasse

src/test/util_threadnames_tests.cpp:29–48  ·  view source on GitHub ↗

* Run a bunch of threads to all call util::ThreadRename. * * @return the set of name each thread has after attempted renaming. */

Source from the content-addressed store, hash-verified

27 * @return the set of name each thread has after attempted renaming.
28 */
29std::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

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 4

ToStringFunction · 0.50
insertMethod · 0.45
push_backMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected