diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/thread/factory.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/thread/factory.h')
-rw-r--r-- | util/thread/factory.h | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/util/thread/factory.h b/util/thread/factory.h index 9393f0f3092..561fcbac889 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); |