MCPcopy Create free account
hub / github.com/catboost/catboost / TestEnumeratedThreadName

Function TestEnumeratedThreadName

util/thread/pool_ut.cpp:206–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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";

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 4

SafeAddFuncMethod · 0.80
StartMethod · 0.45
sizeMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected