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 | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /util/thread/singleton.h | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/thread/singleton.h')
-rw-r--r-- | util/thread/singleton.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/util/thread/singleton.h b/util/thread/singleton.h index 4a1e05aea0..e9d43bcf20 100644 --- a/util/thread/singleton.h +++ b/util/thread/singleton.h @@ -1,20 +1,20 @@ -#pragma once - -#include <util/system/tls.h> -#include <util/generic/singleton.h> -#include <util/generic/ptr.h> - +#pragma once + +#include <util/system/tls.h> +#include <util/generic/singleton.h> +#include <util/generic/ptr.h> + namespace NPrivate { template <class T, size_t Priority> struct TFastThreadSingletonHelper { static inline T* GetSlow() { return SingletonWithPriority<NTls::TValue<T>, Priority>()->GetPtr(); } - + static inline T* Get() { #if defined(Y_HAVE_FAST_POD_TLS) Y_POD_STATIC_THREAD(T*) fast(nullptr); - + if (Y_UNLIKELY(!fast)) { fast = GetSlow(); } @@ -25,16 +25,16 @@ namespace NPrivate { #endif } }; -} - +} + template <class T, size_t Priority> static inline T* FastTlsSingletonWithPriority() { return ::NPrivate::TFastThreadSingletonHelper<T, Priority>::Get(); -} - -// NB: the singleton is the same for all modules that use -// FastTlsSingleton with the same type parameter. If unique singleton -// required, use unique types. +} + +// NB: the singleton is the same for all modules that use +// FastTlsSingleton with the same type parameter. If unique singleton +// required, use unique types. template <class T> static inline T* FastTlsSingleton() { return FastTlsSingletonWithPriority<T, TSingletonTraits<T>::Priority>(); |