diff options
author | svshevtsov <[email protected]> | 2022-02-10 16:49:37 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:37 +0300 |
commit | de89752358147d7b25ef59a85b431bb564068a49 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system | |
parent | 657337012a264721d58c470b4e9e796611f3c492 (diff) |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r-- | util/system/file_lock.cpp | 26 | ||||
-rw-r--r-- | util/system/file_lock.h | 2 | ||||
-rw-r--r-- | util/system/flock_ut.cpp | 6 | ||||
-rw-r--r-- | util/system/guard.h | 12 | ||||
-rw-r--r-- | util/system/rusage.cpp | 4 | ||||
-rw-r--r-- | util/system/rusage.h | 2 |
6 files changed, 26 insertions, 26 deletions
diff --git a/util/system/file_lock.cpp b/util/system/file_lock.cpp index 81558eb09fb..45d91282c5b 100644 --- a/util/system/file_lock.cpp +++ b/util/system/file_lock.cpp @@ -1,10 +1,10 @@ #include "file_lock.h" #include "flock.h" -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #include <cerrno> - + namespace { int GetMode(const EFileLockType type) { switch (type) { @@ -29,18 +29,18 @@ void TFileLock::Acquire() { Flock(GetMode(Type)); } -bool TFileLock::TryAcquire() { - try { +bool TFileLock::TryAcquire() { + try { Flock(GetMode(Type) | LOCK_NB); - return true; - } catch (const TSystemError& e) { - if (e.Status() != EWOULDBLOCK) { - throw; - } - return false; - } -} - + return true; + } catch (const TSystemError& e) { + if (e.Status() != EWOULDBLOCK) { + throw; + } + return false; + } +} + void TFileLock::Release() { Flock(LOCK_UN); } diff --git a/util/system/file_lock.h b/util/system/file_lock.h index 5921d9a7071..b2aaff5baf8 100644 --- a/util/system/file_lock.h +++ b/util/system/file_lock.h @@ -14,7 +14,7 @@ public: TFileLock(const TString& filename, const EFileLockType type = EFileLockType::Exclusive); void Acquire(); - bool TryAcquire(); + bool TryAcquire(); void Release(); inline void lock() { diff --git a/util/system/flock_ut.cpp b/util/system/flock_ut.cpp index 26afbbc0478..b5f6cb53287 100644 --- a/util/system/flock_ut.cpp +++ b/util/system/flock_ut.cpp @@ -23,10 +23,10 @@ Y_UNIT_TEST_SUITE(TFileLockTest) { { TGuard<TFileLock> guard(fileLockExclusive1); } - { + { TTryGuard<TFileLock> tryGuard(fileLockExclusive1); - UNIT_ASSERT(tryGuard.WasAcquired()); - } + UNIT_ASSERT(tryGuard.WasAcquired()); + } { TGuard<TFileLock> guard1(fileLockExclusive1); TTryGuard<TFileLock> guard2(fileLockExclusive2); diff --git a/util/system/guard.h b/util/system/guard.h index b92d6432dd3..efc091d5f8d 100644 --- a/util/system/guard.h +++ b/util/system/guard.h @@ -137,12 +137,12 @@ public: Init(t); } - inline TTryGuard(TTryGuard&& g) noexcept - : T_(g.T_) - { - g.T_ = nullptr; - } - + inline TTryGuard(TTryGuard&& g) noexcept + : T_(g.T_) + { + g.T_ = nullptr; + } + inline ~TTryGuard() { Release(); } diff --git a/util/system/rusage.cpp b/util/system/rusage.cpp index 4d15a48a7d7..2befeca8755 100644 --- a/util/system/rusage.cpp +++ b/util/system/rusage.cpp @@ -99,7 +99,7 @@ void TRusage::Fill() { } MaxRss = pmc.PeakWorkingSetSize; - MajorPageFaults = pmc.PageFaultCount; + MajorPageFaults = pmc.PageFaultCount; #else struct rusage ru; @@ -114,7 +114,7 @@ void TRusage::Fill() { #else MaxRss = ru.ru_maxrss * 1024LL; #endif - MajorPageFaults = ru.ru_majflt; + MajorPageFaults = ru.ru_majflt; Utime = ru.ru_utime; Stime = ru.ru_stime; #endif diff --git a/util/system/rusage.h b/util/system/rusage.h index bb3725a7f77..61aeca83f25 100644 --- a/util/system/rusage.h +++ b/util/system/rusage.h @@ -10,7 +10,7 @@ struct TRusage { // some fields may be zero if unsupported ui64 MaxRss = 0; - ui64 MajorPageFaults = 0; + ui64 MajorPageFaults = 0; TDuration Utime; TDuration Stime; |