From 7199613d295246a07c2f7b331fbb3128936039dc Mon Sep 17 00:00:00 2001 From: gulin Date: Thu, 10 Feb 2022 16:47:32 +0300 Subject: Restoring authorship annotation for . Commit 2 of 2. --- .../threading/local_executor/local_executor.cpp | 36 +++++++++++----------- .../cpp/threading/local_executor/local_executor.h | 14 ++++----- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'library/cpp/threading/local_executor') diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 271e7634980..1d3fbb4bf44 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -5,24 +5,24 @@ #include #include #include -#include +#include #include -#include +#include #include - + #include -#ifdef _win_ +#ifdef _win_ static void RegularYield() { -} -#else -// unix actually has cooperative multitasking! :) -// without this function program runs slower and system lags for some magic reason +} +#else +// unix actually has cooperative multitasking! :) +// without this function program runs slower and system lags for some magic reason static void RegularYield() { - SchedYield(); -} -#endif - + SchedYield(); +} +#endif + namespace { struct TFunctionWrapper : NPar::ILocallyExecutable { NPar::TLocallyExecutableFunction Exec; @@ -79,15 +79,15 @@ namespace { : Exec(std::move(exec)) , Id(id) { - } + } }; - + class TLocalRangeExecutor: public NPar::ILocallyExecutable { TIntrusivePtr Exec; alignas(64) TAtomic Counter; alignas(64) TAtomic WorkerCount; int LastId; - + void LocalExec(int) override { AtomicAdd(WorkerCount, 1); for (;;) { @@ -96,7 +96,7 @@ namespace { } AtomicAdd(WorkerCount, -1); } - + public: TLocalRangeExecutor(TIntrusivePtr exec, int firstId, int lastId) : Exec(std::move(exec)) @@ -121,8 +121,8 @@ namespace { return Max(LastId - Counter, 0); } }; - -} + +} ////////////////////////////////////////////////////////////////////////// class NPar::TLocalExecutor::TImpl { diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index 0fdd20454b5..c1c824f67cb 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -1,5 +1,5 @@ -#pragma once - +#pragma once + #include #include @@ -10,7 +10,7 @@ #include #include - + namespace NPar { struct ILocallyExecutable : virtual public TThrRefBase { // Must be implemented by the end user to define job that will be processed by one of @@ -20,7 +20,7 @@ namespace NPar { // some dummy value, e.g. `0`. virtual void LocalExec(int id) = 0; }; - + // Alternative and simpler way of describing a job for executor. Function argument has the // same meaning as `id` in `ILocallyExecutable::LocalExec`. // @@ -196,8 +196,8 @@ namespace NPar { } return false; } - }; - + }; + // `TLocalExecutor` provides facilities for easy parallelization of existing code and cycles. // // Examples: @@ -291,4 +291,4 @@ namespace NPar { params.SetBlockCountToThreadCount(); LocalExecutor().ExecRange(std::forward(body), params, 0); } -} +} -- cgit v1.3