diff options
author | risenberg <risenberg@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
commit | ec551e975caf33bd88e2803b55464cad608e2441 (patch) | |
tree | d2f84f5b97ecb84201832f831b261817be37fbfe /util/generic | |
parent | 6a705ee267e43301156c202a4b371d47ddd4dd4f (diff) | |
download | ydb-ec551e975caf33bd88e2803b55464cad608e2441.tar.gz |
Restoring authorship annotation for <risenberg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/refcount.h | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/util/generic/refcount.h b/util/generic/refcount.h index 966e853b77..d6b857e6c1 100644 --- a/util/generic/refcount.h +++ b/util/generic/refcount.h @@ -8,7 +8,7 @@ template <class TCounterCheckPolicy> class TSimpleCounterTemplate: public TCounterCheckPolicy { using TCounterCheckPolicy::Check; - + public: inline TSimpleCounterTemplate(long initial = 0) noexcept : Counter_(initial) @@ -54,41 +54,41 @@ public: private: TAtomicBase Counter_; -}; - -class TNoCheckPolicy { -protected: - inline void Check() const { - } -}; - +}; + +class TNoCheckPolicy { +protected: + inline void Check() const { + } +}; + #if defined(SIMPLE_COUNTER_THREAD_CHECK) #include <util/system/thread.i> -class TCheckPolicy { -public: - inline TCheckPolicy() { - ThreadId = SystemCurrentThreadId(); - } +class TCheckPolicy { +public: + inline TCheckPolicy() { + ThreadId = SystemCurrentThreadId(); + } -protected: - inline void Check() const { +protected: + inline void Check() const { Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter"); - } + } -private: - size_t ThreadId; -}; +private: + size_t ThreadId; +}; #else using TCheckPolicy = TNoCheckPolicy; #endif -// Use this one if access from multiple threads to your pointer is an error and you want to enforce thread checks +// Use this one if access from multiple threads to your pointer is an error and you want to enforce thread checks using TSimpleCounter = TSimpleCounterTemplate<TCheckPolicy>; -// Use this one if you do want to share the pointer between threads, omit thread checks and do the synchronization yourself +// Use this one if you do want to share the pointer between threads, omit thread checks and do the synchronization yourself using TExplicitSimpleCounter = TSimpleCounterTemplate<TNoCheckPolicy>; - + template <class TCounterCheckPolicy> struct TCommonLockOps<TSimpleCounterTemplate<TCounterCheckPolicy>> { static inline void Acquire(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept { |