diff options
author | cobat <cobat@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
commit | 1d2e8a8e9976488ea69a7e4763aa749244f82612 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/threading/local_executor/local_executor.cpp | |
parent | e486e109b08823b61996f2154f0bc6b7c27a4af4 (diff) | |
download | ydb-1d2e8a8e9976488ea69a7e4763aa749244f82612.tar.gz |
Restoring authorship annotation for <cobat@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/local_executor/local_executor.cpp')
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 2605a35166..1d3fbb4bf4 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -36,40 +36,40 @@ namespace { }; class TFunctionWrapperWithPromise: public NPar::ILocallyExecutable { - private: + private: NPar::TLocallyExecutableFunction Exec; - int FirstId, LastId; - TVector<NThreading::TPromise<void>> Promises; + int FirstId, LastId; + TVector<NThreading::TPromise<void>> Promises; - public: + public: TFunctionWrapperWithPromise(NPar::TLocallyExecutableFunction exec, int firstId, int lastId) : Exec(std::move(exec)) - , FirstId(firstId) - , LastId(lastId) - { - Y_ASSERT(FirstId <= LastId); - const int rangeSize = LastId - FirstId; - Promises.resize(rangeSize, NThreading::NewPromise()); - for (auto& promise : Promises) { - promise = NThreading::NewPromise(); - } - } - - void LocalExec(int id) override { - Y_ASSERT(FirstId <= id && id < LastId); - NThreading::NImpl::SetValue(Promises[id - FirstId], [=] { Exec(id); }); - } - - TVector<NThreading::TFuture<void>> GetFutures() const { - TVector<NThreading::TFuture<void>> out; - out.reserve(Promises.ysize()); - for (auto& promise : Promises) { - out.push_back(promise.GetFuture()); - } - return out; - } - }; - + , FirstId(firstId) + , LastId(lastId) + { + Y_ASSERT(FirstId <= LastId); + const int rangeSize = LastId - FirstId; + Promises.resize(rangeSize, NThreading::NewPromise()); + for (auto& promise : Promises) { + promise = NThreading::NewPromise(); + } + } + + void LocalExec(int id) override { + Y_ASSERT(FirstId <= id && id < LastId); + NThreading::NImpl::SetValue(Promises[id - FirstId], [=] { Exec(id); }); + } + + TVector<NThreading::TFuture<void>> GetFutures() const { + TVector<NThreading::TFuture<void>> out; + out.reserve(Promises.ysize()); + for (auto& promise : Promises) { + out.push_back(promise.GetFuture()); + } + return out; + } + }; + struct TSingleJob { TIntrusivePtr<NPar::ILocallyExecutable> Exec; int Id{0}; |