aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-30 16:25:50 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-30 16:33:12 +0300
commit65c7baa2cd6b62f063b4080c1fcce58114777c87 (patch)
treee9b340df16b3d8b81c7fa0c228dde95c1e6b0869
parent8f148709a6455eab65c8a7e2b7b0f6e9153fa179 (diff)
downloadydb-65c7baa2cd6b62f063b4080c1fcce58114777c87.tar.gz
Intermediate changes
-rw-r--r--yt/yt/core/actions/unittests/actions_ut.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/yt/yt/core/actions/unittests/actions_ut.cpp b/yt/yt/core/actions/unittests/actions_ut.cpp
index f2c54e04e7d..2f3c7343087 100644
--- a/yt/yt/core/actions/unittests/actions_ut.cpp
+++ b/yt/yt/core/actions/unittests/actions_ut.cpp
@@ -94,16 +94,18 @@ TEST(TestCancelableRunWithBoundedConcurrency, TestCancelation)
TEST(TestAllSucceededBoundedConcurrency, TestAllSucceededFail)
{
+ using TCounter = std::atomic<int>;
+
auto threadPool = CreateThreadPool(4, "ThreadPool");
- std::atomic<int> x = 0;
- std::atomic<int> startingSleepCount = 0;
- std::atomic<int> finishedSleepCount = 0;
+ auto x = std::make_shared<TCounter>(0);
+ auto startingSleepCount = std::make_shared<TCounter>(0);
+ auto finishedSleepCount = std::make_shared<TCounter>(0);
std::vector<TCallback<TFuture<void>()>> callbacks;
for (int i = 0; i < 9; ++i) {
- callbacks.emplace_back(BIND([&]() mutable {
- int cur_x = x++;
+ callbacks.emplace_back(BIND([x, startingSleepCount, finishedSleepCount]() mutable {
+ int cur_x = (*x)++;
if (cur_x < 5) {
return;
} else if (cur_x == 5) {
@@ -112,9 +114,9 @@ TEST(TestAllSucceededBoundedConcurrency, TestAllSucceededFail)
THROW_ERROR_EXCEPTION("My Error");
}
- startingSleepCount++;
+ (*startingSleepCount)++;
Sleep(TDuration::MilliSeconds(50));
- finishedSleepCount++;
+ (*finishedSleepCount)++;
})
.AsyncVia(threadPool->GetInvoker()));
}
@@ -128,9 +130,9 @@ TEST(TestAllSucceededBoundedConcurrency, TestAllSucceededFail)
EXPECT_EQ(result.GetCode(), NYT::EErrorCode::Generic);
EXPECT_EQ(result.GetMessage(), "My Error");
- EXPECT_EQ(x, 9);
- EXPECT_EQ(startingSleepCount, 3);
- EXPECT_EQ(finishedSleepCount, 0);
+ EXPECT_EQ(x->load(), 9);
+ EXPECT_EQ(startingSleepCount->load(), 3);
+ EXPECT_EQ(finishedSleepCount->load(), 0);
}
////////////////////////////////////////////////////////////////////////////////