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

Function Y_UNIT_TEST

library/cpp/threading/future/future_mt_ut.cpp:144–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142
143Y_UNIT_TEST_SUITE(TFutureMultiThreadedTest) {
144 Y_UNIT_TEST(WaitAll) {
145 RunWaitTest(
146 [](auto snapshotter) {
147 return [=]() {
148 auto* futures = snapshotter().Futures;
149
150 auto all = WaitNoOpt<TWaitPolicy::TAll>(*futures);
151
152 // tests safety part
153 all.Subscribe([=] (auto&& all) {
154 TStateSnapshot snap = snapshotter();
155
156 // value safety: all is set => every future is set
157 UNIT_ASSERT(all.HasValue() <= ((snap.Started == (i64)snap.Futures->size()) && !snap.StartedException));
158
159 // safety for hasException: all is set => every future is set and some has exception
160 UNIT_ASSERT(all.HasException() <= ((snap.Started == (i64)snap.Futures->size()) && snap.StartedException > 0));
161 });
162
163 // test liveness
164 all.Wait();
165 };
166 });
167 }
168
169 Y_UNIT_TEST(WaitAny) {
170 RunWaitTest(

Callers

nothing calls this directly

Calls 7

RunWaitTestFunction · 0.85
WaitExceptionOrAllFunction · 0.50
SubscribeMethod · 0.45
HasValueMethod · 0.45
sizeMethod · 0.45
HasExceptionMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected