summaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/logger/rotating_file.cpp22
-rw-r--r--library/cpp/logger/ya.make1
2 files changed, 11 insertions, 12 deletions
diff --git a/library/cpp/logger/rotating_file.cpp b/library/cpp/logger/rotating_file.cpp
index bab6f0067c6..aa27e9a79bb 100644
--- a/library/cpp/logger/rotating_file.cpp
+++ b/library/cpp/logger/rotating_file.cpp
@@ -6,7 +6,8 @@
#include <util/system/fstat.h>
#include <util/system/rwlock.h>
#include <util/system/fs.h>
-#include <library/cpp/deprecated/atomic/atomic.h>
+
+#include <atomic>
/*
* rotating file log
@@ -29,10 +30,10 @@ public:
Y_ENSURE(RotatedFilesCount_ != 0);
}
- inline void WriteData(const TLogRecord& rec) {
- if (static_cast<ui64>(AtomicGet(Size_)) > MaxSizeBytes_) {
+ void WriteData(const TLogRecord& rec) {
+ if (Size_.load() > MaxSizeBytes_) {
TWriteGuard guard(Lock_);
- if (static_cast<ui64>(AtomicGet(Size_)) > MaxSizeBytes_) {
+ if (Y_LIKELY(Size_.load() > MaxSizeBytes_)) {
TString newLogPath(TStringBuilder{} << Path_ << "." << RotatedFilesCount_);
for (size_t fileId = RotatedFilesCount_ - 1; fileId; --fileId) {
TString oldLogPath(TStringBuilder{} << Path_ << "." << fileId);
@@ -41,19 +42,19 @@ public:
}
NFs::Rename(Path_, newLogPath);
Log_.ReopenLog();
- AtomicSet(Size_, 0);
+ Size_.store(0);
}
}
TReadGuard guard(Lock_);
Log_.WriteData(rec);
- AtomicAdd(Size_, rec.Len);
+ Size_ += rec.Len;
}
- inline void ReopenLog() {
+ void ReopenLog() {
TWriteGuard guard(Lock_);
Log_.ReopenLog();
- AtomicSet(Size_, TFileStat(Path_).Size);
+ Size_.store(TFileStat(Path_).Size);
}
private:
@@ -61,7 +62,7 @@ private:
TFileLogBackend Log_;
const TString Path_;
const ui64 MaxSizeBytes_;
- TAtomic Size_;
+ std::atomic<ui64> Size_;
const ui32 RotatedFilesCount_;
};
@@ -70,8 +71,7 @@ TRotatingFileLogBackend::TRotatingFileLogBackend(const TString& path, const ui64
{
}
-TRotatingFileLogBackend::~TRotatingFileLogBackend() {
-}
+TRotatingFileLogBackend::~TRotatingFileLogBackend() = default;
void TRotatingFileLogBackend::WriteData(const TLogRecord& rec) {
Impl_->WriteData(rec);
diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make
index 5e426eb32ee..07c269faff1 100644
--- a/library/cpp/logger/ya.make
+++ b/library/cpp/logger/ya.make
@@ -4,7 +4,6 @@ GENERATE_ENUM_SERIALIZATION(priority.h)
PEERDIR(
library/cpp/json
- library/cpp/deprecated/atomic
)
SRCS(