aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreeight <eeight@yandex-team.ru>2022-05-17 10:48:10 +0300
committereeight <eeight@yandex-team.ru>2022-05-17 10:48:10 +0300
commit1e1dfc1b3545147948cc2190bb15161f630507e9 (patch)
tree7a45215faf217a9074d7b18513cbdf9f3edcc27d
parentf3ec69ca4abe595abc22fe786710538cfc9b016a (diff)
downloadydb-1e1dfc1b3545147948cc2190bb15161f630507e9.tar.gz
IGNIETFERRO-1105 Get rid of TAtomic in thread/pool.cpp
ref:3fa56aa890b75b7301a3193c2ee40106281a71cb
-rw-r--r--util/thread/pool.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp
index fafb56ec40e..a3d4122246e 100644
--- a/util/thread/pool.cpp
+++ b/util/thread/pool.cpp
@@ -366,7 +366,7 @@ void TThreadPool::Stop() noexcept {
Impl_.Destroy();
}
-static TAtomic mtp_queue_counter = 0;
+static std::atomic<long> MtpQueueCounter = 0;
class TAdaptiveThreadPool::TImpl {
public:
@@ -427,7 +427,7 @@ public:
, Free_(0)
, IdleTime_(TDuration::Max())
{
- sprintf(Name_, "[mtp queue %ld]", (long)AtomicAdd(mtp_queue_counter, 1));
+ sprintf(Name_, "[mtp queue %ld]", ++MtpQueueCounter);
}
inline ~TImpl() {
@@ -471,16 +471,16 @@ public:
}
inline size_t Size() const noexcept {
- return (size_t)ThrCount_;
+ return ThrCount_.load();
}
private:
inline void IncThreadCount() noexcept {
- AtomicAdd(ThrCount_, 1);
+ ++ThrCount_;
}
inline void DecThreadCount() noexcept {
- AtomicAdd(ThrCount_, -1);
+ --ThrCount_;
}
inline void AddThreadNoLock() {
@@ -500,7 +500,7 @@ private:
AllDone_ = true;
- while (AtomicGet(ThrCount_)) {
+ while (ThrCount_.load()) {
Mutex_.Release();
CondReady_.Signal();
Mutex_.Acquire();
@@ -535,7 +535,7 @@ private:
TAdaptiveThreadPool* Parent_;
const bool Catching;
TThreadNamer Namer;
- TAtomic ThrCount_;
+ std::atomic<size_t> ThrCount_;
TMutex Mutex_;
TCondVar CondReady_;
TCondVar CondFree_;