Skip to content

Commit e4faf1a

Browse files
committed
replaced future promise with std::latch
1 parent dac2122 commit e4faf1a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cloud/storage/core/libs/common/thread_pool_ut.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <util/generic/scope.h>
88

9+
#include <latch>
910
#include <thread>
1011

1112
namespace NCloud {
@@ -37,22 +38,21 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest)
3738
{
3839
auto threadPool = CreateThreadPool("thread", 1);
3940

40-
auto promise = NThreading::NewPromise();
41-
42-
auto future = promise.GetFuture();
41+
std::latch enqueued{1};
4342

4443
std::thread thread(
45-
[threadPool, promise = std::move(promise)]() mutable
44+
[&]() mutable
4645
{
47-
promise.SetValue();
46+
enqueued.count_down();
4847
auto future = threadPool->Execute([] { return 42; });
4948

5049
UNIT_ASSERT_EQUAL(future.GetValue(WaitTimeout), 42);
5150
});
5251

53-
future.GetValueSync();
52+
enqueued.wait();
5453

55-
// Sleep to be sure that task will be enqueued before start.
54+
// Sleep to be sure that the thread will call the AllocateWorker
55+
// function before the thread pool starts.
5656
Sleep(TDuration::Seconds(1));
5757

5858
threadPool->Start();

0 commit comments

Comments
 (0)