/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/threading/future/subscription/wait_ut_common.cpp
26 строк
683 B
arigachnyy
fix nbs opensource
02 окт 2023, 23:02
02 окт 2023, 23:02
8165e47
Код
Авторство
О чём код?
#include "wait_ut_common.h" #include <util/random/shuffle.h> #include <util/system/event.h> #include <util/thread/pool.h> namespace NThreading::NTest::NPrivate { void ExecuteAndWait(TVector<std::function<void()>> jobs, TFuture<void> waiter, size_t threads) { Y_ENSURE(threads > 0); Shuffle(jobs.begin(), jobs.end()); auto pool = CreateThreadPool(threads); TManualEvent start; for (auto& j : jobs) { pool->SafeAddFunc( [&start, job = std::move(j)]() { start.WaitI(); job(); }); } start.Signal(); waiter.Wait(); pool->Stop(); } }