| 204 | } |
| 205 | |
| 206 | void TestEnumeratedThreadName(IThreadPool& pool, const THashSet<TString>& expectedNames) { |
| 207 | pool.Start(expectedNames.size()); |
| 208 | TMutex lock; |
| 209 | TCondVar allReady; |
| 210 | size_t readyCount = 0; |
| 211 | THashSet<TString> names; |
| 212 | for (size_t i = 0; i < expectedNames.size(); ++i) { |
| 213 | pool.SafeAddFunc([&]() { |
| 214 | with_lock (lock) { |
| 215 | if (++readyCount == expectedNames.size()) { |
| 216 | allReady.BroadCast(); |
| 217 | } else { |
| 218 | while (readyCount != expectedNames.size()) { |
| 219 | allReady.WaitI(lock); |
| 220 | } |
| 221 | } |
| 222 | names.insert(TThread::CurrentThreadName()); |
| 223 | } |
| 224 | }); |
| 225 | } |
| 226 | pool.Stop(); |
| 227 | if (TThread::CanGetCurrentThreadName()) { |
| 228 | UNIT_ASSERT_EQUAL(names, expectedNames); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | Y_UNIT_TEST(TestEnumeratedThreadName) { |
| 233 | const TString namePrefix = "HelloWorld"; |
no test coverage detected