diff options
author | iseg <iseg@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
commit | 8b71ce88bea710a9663bb143e4916f961c57212e (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system/mutex.cpp | |
parent | f828a15ab90e9ca8e848f83caf95c95f06be46e7 (diff) | |
download | ydb-8b71ce88bea710a9663bb143e4916f961c57212e.tar.gz |
Restoring authorship annotation for <iseg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/mutex.cpp')
-rw-r--r-- | util/system/mutex.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp index 9b36c272a5..4041402db9 100644 --- a/util/system/mutex.cpp +++ b/util/system/mutex.cpp @@ -7,14 +7,14 @@ #include "winint.h" #else #include <pthread.h> -#endif - +#endif + class TMutex::TImpl { public: inline TImpl() { #if defined(_win_) InitializeCriticalSection(&Obj); -#else +#else struct T { pthread_mutexattr_t Attr; @@ -43,25 +43,25 @@ public: if (result != 0) { ythrow yexception() << "mutex init failed(" << LastSystemErrorText(result) << ")"; } -#endif +#endif } - + inline ~TImpl() { #if defined(_win_) DeleteCriticalSection(&Obj); -#else +#else int result = pthread_mutex_destroy(&Obj); Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result)); -#endif +#endif } inline void Acquire() noexcept { #if defined(_win_) EnterCriticalSection(&Obj); -#else +#else int result = pthread_mutex_lock(&Obj); Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result)); -#endif +#endif } #if defined(_win_) @@ -90,22 +90,22 @@ public: inline bool TryAcquire() noexcept { #if defined(_win_) return TryEnterCriticalSectionInt(&Obj); -#else +#else int result = pthread_mutex_trylock(&Obj); if (result == 0 || result == EBUSY) { return result == 0; } Y_FAIL("mutex trylock failure (%s)", LastSystemErrorText(result)); -#endif +#endif } inline void Release() noexcept { #if defined(_win_) LeaveCriticalSection(&Obj); -#else +#else int result = pthread_mutex_unlock(&Obj); Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result)); -#endif +#endif } inline void* Handle() const noexcept { @@ -123,8 +123,8 @@ private: TMutex::TMutex() : Impl_(new TImpl()) { -} - +} + TMutex::TMutex(TMutex&&) = default; TMutex::~TMutex() = default; |