diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | c2a1af049e9deca890e9923abe64fe6c59060348 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/extra_ref.h | |
parent | 1f553f46fb4f3c5eec631352cdd900a0709016af (diff) | |
download | ydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/extra_ref.h')
-rw-r--r-- | library/cpp/messagebus/extra_ref.h | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/library/cpp/messagebus/extra_ref.h b/library/cpp/messagebus/extra_ref.h index d20b9b6aa1..2927123266 100644 --- a/library/cpp/messagebus/extra_ref.h +++ b/library/cpp/messagebus/extra_ref.h @@ -1,36 +1,36 @@ -#pragma once - -#include <util/system/yassert.h> - -class TExtraRef { - TAtomic Holds; - -public: +#pragma once + +#include <util/system/yassert.h> + +class TExtraRef { + TAtomic Holds; + +public: TExtraRef() : Holds(false) { } - ~TExtraRef() { + ~TExtraRef() { Y_VERIFY(!Holds); - } - - template <typename TThis> - void Retain(TThis* thiz) { - if (AtomicGet(Holds)) { - return; - } - if (AtomicCas(&Holds, 1, 0)) { - thiz->Ref(); - } - } - - template <typename TThis> - void Release(TThis* thiz) { - if (!AtomicGet(Holds)) { - return; - } - if (AtomicCas(&Holds, 0, 1)) { - thiz->UnRef(); - } - } -}; + } + + template <typename TThis> + void Retain(TThis* thiz) { + if (AtomicGet(Holds)) { + return; + } + if (AtomicCas(&Holds, 1, 0)) { + thiz->Ref(); + } + } + + template <typename TThis> + void Release(TThis* thiz) { + if (!AtomicGet(Holds)) { + return; + } + if (AtomicCas(&Holds, 0, 1)) { + thiz->UnRef(); + } + } +}; |