summaryrefslogtreecommitdiffstats
path: root/util/system/mutex.cpp
diff options
context:
space:
mode:
authoriseg <[email protected]>2022-02-10 16:49:39 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:49:39 +0300
commitf828a15ab90e9ca8e848f83caf95c95f06be46e7 (patch)
treede25241f7ec727b05ff1e5b9e1336f567f788a44 /util/system/mutex.cpp
parent8124e2bb214b063687e0d77c900150c727e16782 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/system/mutex.cpp')
-rw-r--r--util/system/mutex.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp
index 4041402db9a..9b36c272a52 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;