aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/guard.h
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:25 +0300
commit344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/system/guard.h
parent706b83ed7de5a473436620367af31fc0ceecde07 (diff)
downloadydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'util/system/guard.h')
-rw-r--r--util/system/guard.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/util/system/guard.h b/util/system/guard.h
index 19c4491424..efc091d5f8 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -8,14 +8,14 @@ struct TCommonLockOps {
t->Acquire();
}
- static inline void Release(T* t) noexcept {
+ static inline void Release(T* t) noexcept {
t->Release();
}
};
template <class T>
struct TTryLockOps: public TCommonLockOps<T> {
- static inline bool TryAcquire(T* t) noexcept {
+ static inline bool TryAcquire(T* t) noexcept {
return t->TryAcquire();
}
};
@@ -24,7 +24,7 @@ struct TTryLockOps: public TCommonLockOps<T> {
template <class TOps>
struct TInverseLockOps: public TOps {
template <class T>
- static inline void Acquire(T* t) noexcept {
+ static inline void Acquire(T* t) noexcept {
TOps::Release(t);
}
@@ -45,32 +45,32 @@ public:
Init(t);
}
- inline TGuard(TGuard&& g) noexcept
+ inline TGuard(TGuard&& g) noexcept
: T_(g.T_)
{
g.T_ = nullptr;
}
- inline ~TGuard() {
+ inline ~TGuard() {
Release();
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
T_ = nullptr;
}
}
- explicit inline operator bool() const noexcept {
+ explicit inline operator bool() const noexcept {
return WasAcquired();
}
- inline bool WasAcquired() const noexcept {
+ inline bool WasAcquired() const noexcept {
return T_ != nullptr;
}
- inline T* GetMutex() const noexcept {
+ inline T* GetMutex() const noexcept {
return T_;
}
@@ -129,11 +129,11 @@ static inline TInverseGuard<T> Unguard(const T& mutex) {
template <class T, class TOps = TTryLockOps<T>>
class TTryGuard: public TNonCopyable {
public:
- inline TTryGuard(const T& t) noexcept {
+ inline TTryGuard(const T& t) noexcept {
Init(&t);
}
- inline TTryGuard(const T* t) noexcept {
+ inline TTryGuard(const T* t) noexcept {
Init(t);
}
@@ -143,27 +143,27 @@ public:
g.T_ = nullptr;
}
- inline ~TTryGuard() {
+ inline ~TTryGuard() {
Release();
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
T_ = nullptr;
}
}
- inline bool WasAcquired() const noexcept {
+ inline bool WasAcquired() const noexcept {
return T_ != nullptr;
}
- explicit inline operator bool() const noexcept {
+ explicit inline operator bool() const noexcept {
return WasAcquired();
}
private:
- inline void Init(const T* t) noexcept {
+ inline void Init(const T* t) noexcept {
T_ = nullptr;
T* tMutable = const_cast<T*>(t);
if (TOps::TryAcquire(tMutable)) {