diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:25 +0300 |
commit | 344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/generic/singleton.cpp | |
parent | 706b83ed7de5a473436620367af31fc0ceecde07 (diff) | |
download | ydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic/singleton.cpp')
-rw-r--r-- | util/generic/singleton.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp index cec1e997f1..eb5a0662f8 100644 --- a/util/generic/singleton.cpp +++ b/util/generic/singleton.cpp @@ -7,15 +7,15 @@ #include <cstring> namespace { - static inline bool MyAtomicTryLock(TAtomic& a, TAtomicBase v) noexcept { + static inline bool MyAtomicTryLock(TAtomic& a, TAtomicBase v) noexcept { return AtomicCas(&a, v, 0); } - static inline bool MyAtomicTryAndTryLock(TAtomic& a, TAtomicBase v) noexcept { + static inline bool MyAtomicTryAndTryLock(TAtomic& a, TAtomicBase v) noexcept { return (AtomicGet(a) == 0) && MyAtomicTryLock(a, v); } - static inline TAtomicBase MyThreadId() noexcept { + static inline TAtomicBase MyThreadId() noexcept { const TAtomicBase ret = TThread::CurrentThreadId(); if (ret) { @@ -41,7 +41,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) { #endif } -void NPrivate::LockRecursive(TAtomic& lock) noexcept { +void NPrivate::LockRecursive(TAtomic& lock) noexcept { const TAtomicBase id = MyThreadId(); Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization"); @@ -55,7 +55,7 @@ void NPrivate::LockRecursive(TAtomic& lock) noexcept { } } -void NPrivate::UnlockRecursive(TAtomic& lock) noexcept { +void NPrivate::UnlockRecursive(TAtomic& lock) noexcept { Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!"); AtomicUnlock(&lock); } |