diff options
author | Anna Veronika Dorogush <annaveronika@yandex-team.ru> | 2022-02-10 16:51:00 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:00 +0300 |
commit | 422daa60ebc422624f4621c54ad0e600134cc621 (patch) | |
tree | 72775ca306f3556fef10c3d0498a6aad0f1557b9 | |
parent | 3fd404e3c028261bd5c6720cd67d4b755740d161 (diff) | |
download | ydb-422daa60ebc422624f4621c54ad0e600134cc621.tar.gz |
Restoring authorship annotation for Anna Veronika Dorogush <annaveronika@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/threading/local_executor/README.md | 28 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.cpp | 6 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.h | 26 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/ya.make | 18 |
4 files changed, 39 insertions, 39 deletions
diff --git a/library/cpp/threading/local_executor/README.md b/library/cpp/threading/local_executor/README.md index aaad2e2986..b62959a642 100644 --- a/library/cpp/threading/local_executor/README.md +++ b/library/cpp/threading/local_executor/README.md @@ -18,21 +18,21 @@ All tasks should be `NPar::ILocallyExecutable` child class or function equal to `void TLocalExecutor::ExecRange(TLocallyExecutableFunction exec, TExecRangeParams blockParams, int flags);` - run range of tasks `[TExecRangeParams::FirstId, TExecRangeParams::LastId).` -`flags` is the same as for `TLocalExecutor::Exec`. - +`flags` is the same as for `TLocalExecutor::Exec`. + `TExecRangeParams` is a structure that describes the range. -By default each task is executed separately. Threads from thread pool are taking -the tasks in the manner first come first serve. - -It is also possible to partition range of tasks in consequtive blocks and execute each block as a bigger task. +By default each task is executed separately. Threads from thread pool are taking +the tasks in the manner first come first serve. + +It is also possible to partition range of tasks in consequtive blocks and execute each block as a bigger task. `TExecRangeParams::SetBlockCountToThreadCount()` will result in thread count tasks, - where thread count is the count of threads in thread pool. - each thread will execute approximately equal count of tasks from range. - + where thread count is the count of threads in thread pool. + each thread will execute approximately equal count of tasks from range. + `TExecRangeParams::SetBlockSize()` and `TExecRangeParams::SetBlockCount()` will partition -the range of tasks into consequtive blocks of approximately given size, or of size calculated - by partitioning the range into approximately equal size blocks of given count. - +the range of tasks into consequtive blocks of approximately given size, or of size calculated + by partitioning the range into approximately equal size blocks of given count. + ## Examples ### Simple task async exec with medium priority @@ -57,10 +57,10 @@ event.WaitI(); using namespace NPar; LocalExecutor().Run(4); -LocalExecutor().ExecRange([](int id) { +LocalExecutor().ExecRange([](int id) { SomeFunc(id); }, TExecRangeParams(0, 10), TLocalExecutor::WAIT_COMPLETE | TLocalExecutor::MED_PRIORITY); -``` +``` ### Exception handling diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 1d3fbb4bf4..e9ddfaf36a 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -1,5 +1,5 @@ -#include "local_executor.h" - +#include "local_executor.h" + #include <library/cpp/threading/future/future.h> #include <util/generic/utility.h> @@ -358,7 +358,7 @@ int NPar::TLocalExecutor::GetLPQueueSize() const noexcept { return AtomicGet(Impl_->LPQueueSize); } -int NPar::TLocalExecutor::GetWorkerThreadId() const noexcept { +int NPar::TLocalExecutor::GetWorkerThreadId() const noexcept { return Impl_->WorkerThreadId; } diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index c1c824f67c..7939198b23 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -68,7 +68,7 @@ namespace NPar { , LastId(SafeIntegerCast<int>(lastId)) { Y_ASSERT(LastId >= FirstId); - SetBlockSize(1); + SetBlockSize(1); } // Partition tasks into `blockCount` blocks of approximately equal size, each of which // will be executed as a separate bigger task. @@ -78,7 +78,7 @@ namespace NPar { Y_ASSERT(SafeIntegerCast<int>(blockCount) > 0 || FirstId == LastId); BlockSize = FirstId == LastId ? 0 : CeilDiv(LastId - FirstId, SafeIntegerCast<int>(blockCount)); BlockCount = BlockSize == 0 ? 0 : CeilDiv(LastId - FirstId, BlockSize); - BlockEqualToThreads = false; + BlockEqualToThreads = false; return *this; } // Partition tasks into blocks of approximately `blockSize` size, each of which will @@ -89,22 +89,22 @@ namespace NPar { Y_ASSERT(SafeIntegerCast<int>(blockSize) > 0 || FirstId == LastId); BlockSize = SafeIntegerCast<int>(blockSize); BlockCount = BlockSize == 0 ? 0 : CeilDiv(LastId - FirstId, BlockSize); - BlockEqualToThreads = false; + BlockEqualToThreads = false; return *this; } // Partition tasks into thread count blocks of approximately equal size, each of which // will be executed as a separate bigger task. // TExecRangeParams& SetBlockCountToThreadCount() { - BlockEqualToThreads = true; - return *this; - } + BlockEqualToThreads = true; + return *this; + } int GetBlockCount() const { - Y_ASSERT(!BlockEqualToThreads); + Y_ASSERT(!BlockEqualToThreads); return BlockCount; } int GetBlockSize() const { - Y_ASSERT(!BlockEqualToThreads); + Y_ASSERT(!BlockEqualToThreads); return BlockSize; } bool GetBlockEqualToThreads() { @@ -115,9 +115,9 @@ namespace NPar { const int LastId = 0; private: - int BlockSize; - int BlockCount; - bool BlockEqualToThreads; + int BlockSize; + int BlockCount; + bool BlockEqualToThreads; }; // `Exec` and `ExecRange` versions that accept functions. @@ -277,7 +277,7 @@ namespace NPar { inline void ParallelFor(ILocalExecutor& executor, ui32 from, ui32 to, TBody&& body) { ILocalExecutor::TExecRangeParams params(from, to); params.SetBlockCountToThreadCount(); - executor.ExecRange(std::forward<TBody>(body), params, TLocalExecutor::WAIT_COMPLETE); + executor.ExecRange(std::forward<TBody>(body), params, TLocalExecutor::WAIT_COMPLETE); } template <typename TBody> @@ -289,6 +289,6 @@ namespace NPar { inline void AsyncParallelFor(ui32 from, ui32 to, TBody&& body) { ILocalExecutor::TExecRangeParams params(from, to); params.SetBlockCountToThreadCount(); - LocalExecutor().ExecRange(std::forward<TBody>(body), params, 0); + LocalExecutor().ExecRange(std::forward<TBody>(body), params, 0); } } diff --git a/library/cpp/threading/local_executor/ya.make b/library/cpp/threading/local_executor/ya.make index df210f92bb..8fa2260112 100644 --- a/library/cpp/threading/local_executor/ya.make +++ b/library/cpp/threading/local_executor/ya.make @@ -1,20 +1,20 @@ -OWNER( +OWNER( g:matrixnet - gulin + gulin kirillovs espetrov -) - +) + LIBRARY() -SRCS( - local_executor.cpp +SRCS( + local_executor.cpp tbb_local_executor.cpp -) - +) + PEERDIR( contrib/libs/tbb library/cpp/threading/future ) -END() +END() |