diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:25 +0300 |
commit | 344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/thread | |
parent | 706b83ed7de5a473436620367af31fc0ceecde07 (diff) | |
download | ydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'util/thread')
-rw-r--r-- | util/thread/factory.cpp | 4 | ||||
-rw-r--r-- | util/thread/factory.h | 4 | ||||
-rw-r--r-- | util/thread/lfqueue.h | 2 | ||||
-rw-r--r-- | util/thread/lfqueue_ut.cpp | 2 | ||||
-rw-r--r-- | util/thread/lfstack.h | 2 | ||||
-rw-r--r-- | util/thread/lfstack_ut.cpp | 16 | ||||
-rw-r--r-- | util/thread/pool.cpp | 42 | ||||
-rw-r--r-- | util/thread/pool.h | 26 | ||||
-rw-r--r-- | util/thread/pool_ut.cpp | 4 |
9 files changed, 51 insertions, 51 deletions
diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp index 463acc8b19..48e898f32d 100644 --- a/util/thread/factory.cpp +++ b/util/thread/factory.cpp @@ -10,7 +10,7 @@ namespace { public: class TPoolThread: public IThread { public: - ~TPoolThread() override { + ~TPoolThread() override { if (Thr_) { Thr_->Detach(); } @@ -22,7 +22,7 @@ namespace { Thr_->Start(); } - void DoJoin() noexcept override { + void DoJoin() noexcept override { if (!Thr_) { return; } diff --git a/util/thread/factory.h b/util/thread/factory.h index 452169e9f7..561fcbac88 100644 --- a/util/thread/factory.h +++ b/util/thread/factory.h @@ -27,7 +27,7 @@ public: virtual ~IThread() = default; - inline void Join() noexcept { + inline void Join() noexcept { DoJoin(); } @@ -39,7 +39,7 @@ public: private: // it's actually DoStart virtual void DoRun(IThreadAble* func) = 0; - virtual void DoJoin() noexcept = 0; + virtual void DoJoin() noexcept = 0; }; inline IThreadFactory() noexcept = default; diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h index 170ae134fe..ab523631e4 100644 --- a/util/thread/lfqueue.h +++ b/util/thread/lfqueue.h @@ -364,7 +364,7 @@ class TAutoLockFreeQueue { public: using TRef = THolder<T>; - inline ~TAutoLockFreeQueue() { + inline ~TAutoLockFreeQueue() { TRef tmp; while (Dequeue(&tmp)) { diff --git a/util/thread/lfqueue_ut.cpp b/util/thread/lfqueue_ut.cpp index f68771a8c4..83bca100cf 100644 --- a/util/thread/lfqueue_ut.cpp +++ b/util/thread/lfqueue_ut.cpp @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) { UNIT_ASSERT(!queue.Dequeue(&i)); UNIT_ASSERT_VALUES_EQUAL(i, -1); - TVector<int> v; + TVector<int> v; v.push_back(20); v.push_back(21); diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h index cdc9f68386..ca3d95f3c3 100644 --- a/util/thread/lfstack.h +++ b/util/thread/lfstack.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/noncopyable.h> +#include <util/generic/noncopyable.h> #include <util/system/atomic.h> ////////////////////////////// diff --git a/util/thread/lfstack_ut.cpp b/util/thread/lfstack_ut.cpp index 61edd3d632..e20a838f95 100644 --- a/util/thread/lfstack_ut.cpp +++ b/util/thread/lfstack_ut.cpp @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { StartLatch.CountDown(); StartLatch.Await(); - TVector<int> temp; + TVector<int> temp; while (AtomicGet(LeftToDequeue) > 0) { size_t dequeued = 0; for (size_t i = 0; i < 100; ++i) { @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { } void Run() { - TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<>>> futures; + TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<>>> futures; for (size_t i = 0; i < EnqueueThreads; ++i) { futures.push_back(new NThreading::TLegacyFuture<>(std::bind(&TDequeueAllTester<SingleConsumer>::Enqueuer, this))); @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { UNIT_ASSERT_VALUES_EQUAL(0, int(AtomicGet(LeftToDequeue))); - TVector<int> left; + TVector<int> left; Stack.DequeueAll(&left); UNIT_ASSERT(left.empty()); } @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { Y_UNIT_TEST(TestDequeueAllEmptyStack) { TLockFreeStack<int> stack; - TVector<int> r; + TVector<int> r; stack.DequeueAll(&r); UNIT_ASSERT(r.empty()); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { stack.Enqueue(19); stack.Enqueue(23); - TVector<int> r; + TVector<int> r; stack.DequeueAll(&r); @@ -143,8 +143,8 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { Y_UNIT_TEST(TestEnqueueAll) { TLockFreeStack<int> stack; - TVector<int> v; - TVector<int> expected; + TVector<int> v; + TVector<int> expected; stack.EnqueueAll(v); // add empty @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) { expected.insert(expected.end(), v.begin(), v.end()); stack.EnqueueAll(v); - TVector<int> actual; + TVector<int> actual; stack.DequeueAll(&actual); UNIT_ASSERT_VALUES_EQUAL(expected.size(), actual.size()); diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index cb87d95e09..05fad02e9b 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -86,7 +86,7 @@ public: Start(thrnum, maxqueue); } - inline ~TImpl() override { + inline ~TImpl() override { try { Stop(); } catch (...) { @@ -129,17 +129,17 @@ public: return true; } - inline size_t Size() const noexcept { + inline size_t Size() const noexcept { auto guard = Guard(QueueMutex); return Queue.Size(); } - inline size_t GetMaxQueueSize() const noexcept { + inline size_t GetMaxQueueSize() const noexcept { return MaxQueueSize; } - inline size_t GetThreadCountExpected() const noexcept { + inline size_t GetThreadCountExpected() const noexcept { return ThreadCountExpected; } @@ -151,7 +151,7 @@ public: Forked = true; } - inline bool NeedRestart() const noexcept { + inline bool NeedRestart() const noexcept { return Forked; } @@ -189,7 +189,7 @@ private: MaxQueueSize = 0; } - inline void WaitForComplete() noexcept { + inline void WaitForComplete() noexcept { with_lock (StopMutex) { while (ThreadCountReal) { with_lock (QueueMutex) { @@ -245,7 +245,7 @@ private: FinishOneThread(); } - inline void FinishOneThread() noexcept { + inline void FinishOneThread() noexcept { auto guard = Guard(StopMutex); --ThreadCountReal; @@ -263,7 +263,7 @@ private: TCondVar QueuePopCond; TCondVar StopCond; TJobQueue Queue; - TVector<TThreadRef> Tharr; + TVector<TThreadRef> Tharr; TAtomic ShouldTerminate; size_t MaxQueueSize; size_t ThreadCountExpected; @@ -379,12 +379,12 @@ public: { } - inline ~TThread() override { + inline ~TThread() override { Impl_->DecThreadCount(); } private: - void DoExecute() noexcept override { + void DoExecute() noexcept override { THolder<TThread> This(this); if (Impl_->Namer) { @@ -431,7 +431,7 @@ public: sprintf(Name_, "[mtp queue %ld]", (long)AtomicAdd(mtp_queue_counter, 1)); } - inline ~TImpl() { + inline ~TImpl() { Stop(); } @@ -439,7 +439,7 @@ public: IdleTime_ = idleTime; } - inline const char* Name() const noexcept { + inline const char* Name() const noexcept { return Name_; } @@ -471,16 +471,16 @@ public: } } - inline size_t Size() const noexcept { + inline size_t Size() const noexcept { return (size_t)ThrCount_; } private: - inline void IncThreadCount() noexcept { + inline void IncThreadCount() noexcept { AtomicAdd(ThrCount_, 1); } - inline void DecThreadCount() noexcept { + inline void DecThreadCount() noexcept { AtomicAdd(ThrCount_, -1); } @@ -496,7 +496,7 @@ private: } } - inline void Stop() noexcept { + inline void Stop() noexcept { Mutex_.Acquire(); AllDone_ = true; @@ -510,7 +510,7 @@ private: Mutex_.Release(); } - inline IObjectInQueue* WaitForJob() noexcept { + inline IObjectInQueue* WaitForJob() noexcept { Mutex_.Acquire(); ++Free_; @@ -690,11 +690,11 @@ namespace { ~TThreadImpl() override = default; - inline void WaitForStart() noexcept { + inline void WaitForStart() noexcept { StartEvent_.Wait(); } - inline void WaitForComplete() noexcept { + inline void WaitForComplete() noexcept { CompleteEvent_.Wait(); } @@ -729,7 +729,7 @@ namespace { { } - ~TPoolThread() override { + ~TPoolThread() override { if (Impl_) { Impl_->WaitForStart(); } @@ -743,7 +743,7 @@ namespace { Impl_.Swap(impl); } - void DoJoin() noexcept override { + void DoJoin() noexcept override { if (Impl_) { Impl_->WaitForComplete(); Impl_ = nullptr; diff --git a/util/thread/pool.h b/util/thread/pool.h index f19c323bd0..d1ea3a67cb 100644 --- a/util/thread/pool.h +++ b/util/thread/pool.h @@ -176,9 +176,9 @@ public: bool AddAndOwn(THolder<IObjectInQueue> obj) Y_WARN_UNUSED_RESULT; virtual void Start(size_t threadCount, size_t queueSizeLimit = 0) = 0; /** Wait for completion of all scheduled objects, and then exit */ - virtual void Stop() noexcept = 0; + virtual void Stop() noexcept = 0; /** Number of tasks currently in queue */ - virtual size_t Size() const noexcept = 0; + virtual size_t Size() const noexcept = 0; public: /** @@ -193,7 +193,7 @@ public: { } - inline ~TTsr() { + inline ~TTsr() { try { Q_->DestroyThreadSpecificResource(Data_); } catch (...) { @@ -201,7 +201,7 @@ public: } } - inline operator void*() noexcept { + inline operator void*() noexcept { return Data_; } @@ -247,10 +247,10 @@ public: void Start(size_t, size_t = 0) override { } - void Stop() noexcept override { + void Stop() noexcept override { } - size_t Size() const noexcept override { + size_t Size() const noexcept override { return 0; } }; @@ -275,8 +275,8 @@ public: * @param threadCount means "single thread" when = 0 */ void Start(size_t threadCount, size_t queueSizeLimit = 0) override; - void Stop() noexcept override; - size_t Size() const noexcept override; + void Stop() noexcept override; + size_t Size() const noexcept override; size_t GetThreadCountExpected() const noexcept; size_t GetThreadCountReal() const noexcept; size_t GetMaxQueueSize() const noexcept; @@ -305,8 +305,8 @@ public: bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT; /** @param thrnum, @param maxque are ignored */ void Start(size_t thrnum = 0, size_t maxque = 0) override; - void Stop() noexcept override; - size_t Size() const noexcept override; + void Stop() noexcept override; + size_t Size() const noexcept override; private: class TImpl; @@ -325,8 +325,8 @@ public: * SetMaxIdleTime interval parameter. if thrnum is not 0, use non-blocking TThreadPool */ void Start(size_t thrnum, size_t maxque = 0) override; - void Stop() noexcept override; - size_t Size() const noexcept override; + void Stop() noexcept override; + size_t Size() const noexcept override; private: THolder<IThreadPool> Slave_; @@ -337,7 +337,7 @@ private: * from IThreadPool and implement them using functions with same name from * pointer to TSlave. */ -template <class TQueueType, class TSlave> +template <class TQueueType, class TSlave> class TThreadPoolBinder: public TQueueType { public: inline TThreadPoolBinder(TSlave* slave) diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp index 71413f4abc..893770d0c4 100644 --- a/util/thread/pool_ut.cpp +++ b/util/thread/pool_ut.cpp @@ -82,10 +82,10 @@ public: void Start(size_t, size_t) override { } - void Stop() noexcept override { + void Stop() noexcept override { } - size_t Size() const noexcept override { + size_t Size() const noexcept override { return 0; } }; |