diff options
| author | kulikov <[email protected]> | 2026-03-20 19:39:06 +0300 |
|---|---|---|
| committer | kulikov <[email protected]> | 2026-03-20 20:17:51 +0300 |
| commit | 14bf6e9ab2e2a49e7b066904080cf9e121a348d9 (patch) | |
| tree | 723aeeaacfc85442b14485526ccf342169640cf0 /library/cpp/threading/equeue/equeue.cpp | |
| parent | 8c1168348ffdcc290ddee600735708101b5f708c (diff) | |
Switch to std atomics
commit_hash:5d980b19ed177f3a4ce03ba7c7d89ab9d711b8e8
Diffstat (limited to 'library/cpp/threading/equeue/equeue.cpp')
| -rw-r--r-- | library/cpp/threading/equeue/equeue.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/library/cpp/threading/equeue/equeue.cpp b/library/cpp/threading/equeue/equeue.cpp index 54a848e912a..54b088635d5 100644 --- a/library/cpp/threading/equeue/equeue.cpp +++ b/library/cpp/threading/equeue/equeue.cpp @@ -6,12 +6,12 @@ TElasticQueue::TElasticQueue(THolder<IThreadPool> slaveQueue) } size_t TElasticQueue::ObjectCount() const { - return (size_t)AtomicGet(ObjectCount_); + return ObjectCount_.load(); } bool TElasticQueue::TryIncCounter() { - if ((size_t)AtomicIncrement(GuardCount_) > MaxQueueSize_) { - AtomicDecrement(GuardCount_); + if (++GuardCount_ > MaxQueueSize_) { + --GuardCount_; return false; } @@ -26,12 +26,12 @@ public: : RealObject_(realObject) , Queue_(queue) { - AtomicIncrement(Queue_->ObjectCount_); + ++Queue_->ObjectCount_; } ~TDecrementingWrapper() override { - AtomicDecrement(Queue_->ObjectCount_); - AtomicDecrement(Queue_->GuardCount_); + --Queue_->ObjectCount_; + --Queue_->GuardCount_; } private: void Process(void *tsr) override { @@ -54,7 +54,7 @@ bool TElasticQueue::Add(IObjectInQueue* obj) { try { wrapper.Reset(new TDecrementingWrapper(obj, this)); } catch (...) { - AtomicDecrement(GuardCount_); + --GuardCount_; throw; } |
