aboutsummaryrefslogtreecommitdiffstats
path: root/util/thread/factory.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/thread/factory.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/thread/factory.h')
-rw-r--r--util/thread/factory.h92
1 files changed, 46 insertions, 46 deletions
diff --git a/util/thread/factory.h b/util/thread/factory.h
index 561fcbac88..9393f0f309 100644
--- a/util/thread/factory.h
+++ b/util/thread/factory.h
@@ -1,65 +1,65 @@
#pragma once
-
+
#include <util/generic/ptr.h>
#include <functional>
-
+
class IThreadFactory {
-public:
- class IThreadAble {
- public:
+public:
+ class IThreadAble {
+ public:
inline IThreadAble() noexcept = default;
-
+
virtual ~IThreadAble() = default;
-
- inline void Execute() {
- DoExecute();
- }
-
- private:
- virtual void DoExecute() = 0;
- };
-
- class IThread {
+
+ inline void Execute() {
+ DoExecute();
+ }
+
+ private:
+ virtual void DoExecute() = 0;
+ };
+
+ class IThread {
friend class IThreadFactory;
-
- public:
+
+ public:
inline IThread() noexcept = default;
-
+
virtual ~IThread() = default;
-
+
inline void Join() noexcept {
- DoJoin();
- }
-
- private:
- inline void Run(IThreadAble* func) {
- DoRun(func);
- }
-
- private:
- // it's actually DoStart
- virtual void DoRun(IThreadAble* func) = 0;
+ DoJoin();
+ }
+
+ private:
+ inline void Run(IThreadAble* func) {
+ DoRun(func);
+ }
+
+ private:
+ // it's actually DoStart
+ virtual void DoRun(IThreadAble* func) = 0;
virtual void DoJoin() noexcept = 0;
- };
-
+ };
+
inline IThreadFactory() noexcept = default;
-
+
virtual ~IThreadFactory() = default;
-
- // XXX: rename to Start
+
+ // XXX: rename to Start
inline THolder<IThread> Run(IThreadAble* func) {
THolder<IThread> ret(DoCreate());
- ret->Run(func);
-
- return ret;
- }
-
+ ret->Run(func);
+
+ return ret;
+ }
+
THolder<IThread> Run(std::function<void()> func);
-
-private:
- virtual IThread* DoCreate() = 0;
-};
-
+
+private:
+ virtual IThread* DoCreate() = 0;
+};
+
IThreadFactory* SystemThreadFactory();
void SetSystemThreadFactory(IThreadFactory* pool);