diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /util/generic/singleton.cpp | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 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 eb5a0662f8..cec1e997f1 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); } |