File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
cloud/storage/core/libs/common Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 66
77#include < util/generic/scope.h>
88
9+ #include < latch>
910#include < thread>
1011
1112namespace 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 ();
You can’t perform that action at this time.
0 commit comments