aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorgulin <gulin@yandex-team.ru>2022-02-10 16:47:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:31 +0300
commitc807aae441c17fc7f577c35757a4b6e0bd909802 (patch)
treefc3268f43edbf6f854c0266cd05b91952484179b /library/cpp/threading
parentd06e6190fa85c1fb4b011631503d53ea39942ff9 (diff)
downloadydb-c807aae441c17fc7f577c35757a4b6e0bd909802.tar.gz
Restoring authorship annotation for <gulin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/local_executor/local_executor.cpp36
-rw-r--r--library/cpp/threading/local_executor/local_executor.h14
2 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp
index 1d3fbb4bf4..271e763498 100644
--- a/library/cpp/threading/local_executor/local_executor.cpp
+++ b/library/cpp/threading/local_executor/local_executor.cpp
@@ -5,24 +5,24 @@
#include <util/generic/utility.h>
#include <util/system/atomic.h>
#include <util/system/event.h>
-#include <util/system/thread.h>
+#include <util/system/thread.h>
#include <util/system/tls.h>
-#include <util/system/yield.h>
+#include <util/system/yield.h>
#include <util/thread/lfqueue.h>
-
+
#include <utility>
-#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<NPar::ILocallyExecutable> 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<ILocallyExecutable> exec, int firstId, int lastId)
: Exec(std::move(exec))
@@ -121,8 +121,8 @@ namespace {
return Max<int>(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 c1c824f67c..0fdd20454b 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 <library/cpp/threading/future/future.h>
#include <util/generic/cast.h>
@@ -10,7 +10,7 @@
#include <util/generic/ymath.h>
#include <functional>
-
+
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<TBody>(body), params, 0);
}
-}
+}