diff options
| author | Anna Veronika Dorogush <[email protected]> | 2022-02-10 16:51:00 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:51:00 +0300 | 
| commit | 9164d180a5c1f96e8d270f59bba1fbc7102889fd (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/threading | |
| parent | 422daa60ebc422624f4621c54ad0e600134cc621 (diff) | |
Restoring authorship annotation for Anna Veronika Dorogush <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading')
| -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 b62959a642d..aaad2e2986c 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 e9ddfaf36a7..1d3fbb4bf44 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 7939198b238..c1c824f67cb 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 8fa2260112c..df210f92bb6 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()  | 
