aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/misc/utils.h
diff options
context:
space:
mode:
authorcerevra <cerevra@yandex-team.ru>2022-02-10 16:45:58 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:58 +0300
commitbf41dd01f6c920583e9faae7cd55ed25e547e052 (patch)
treeec7c8c285ffa648a5c5efeff453787a15ab811ac /library/cpp/tvmauth/client/misc/utils.h
parente2c3e3004f7cd68441cefcfa4aaccd3d8051c846 (diff)
downloadydb-bf41dd01f6c920583e9faae7cd55ed25e547e052.tar.gz
Restoring authorship annotation for <cerevra@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/tvmauth/client/misc/utils.h')
-rw-r--r--library/cpp/tvmauth/client/misc/utils.h190
1 files changed, 95 insertions, 95 deletions
diff --git a/library/cpp/tvmauth/client/misc/utils.h b/library/cpp/tvmauth/client/misc/utils.h
index 1aa5e61bf1..d2333b16fc 100644
--- a/library/cpp/tvmauth/client/misc/utils.h
+++ b/library/cpp/tvmauth/client/misc/utils.h
@@ -1,95 +1,95 @@
-#pragma once
-
-#include "api/settings.h"
-#include "tool/settings.h"
-
-#include <util/string/cast.h>
-#include <util/system/spinlock.h>
-
-#include <optional>
-
-namespace NTvmAuth {
- class TTvmClient;
-}
-
-namespace NTvmAuth::NInternal {
- class TClientCaningKnife {
- public:
- static void StartTvmClientStopping(TTvmClient* c);
- static bool IsTvmClientStopped(TTvmClient* c);
- };
-}
-
-namespace NTvmAuth::NUtils {
- TString ToHex(const TStringBuf s);
-
- inline NTvmAuth::NTvmApi::TClientSettings::TDstMap ParseDstMap(TStringBuf dsts) {
- NTvmAuth::NTvmApi::TClientSettings::TDstMap res;
-
- while (dsts) {
- TStringBuf pair = dsts.NextTok(';');
- TStringBuf alias = pair.NextTok(':');
- res.insert(decltype(res)::value_type(
- alias,
- IntFromString<TTvmId, 10>(pair)));
- }
-
- return res;
- }
-
- inline NTvmAuth::NTvmApi::TClientSettings::TDstVector ParseDstVector(TStringBuf dsts) {
- NTvmAuth::NTvmApi::TClientSettings::TDstVector res;
-
- while (dsts) {
- res.push_back(IntFromString<TTvmId, 10>(dsts.NextTok(';')));
- }
-
- return res;
- }
-
- bool CheckBbEnvOverriding(EBlackboxEnv original, EBlackboxEnv override) noexcept;
-
- template <class T>
- class TProtectedValue {
- class TAssignOp {
- public:
- static void Assign(T& l, const T& r) {
- l = r;
- }
-
- template <typename U>
- static void Assign(std::shared_ptr<U>& l, std::shared_ptr<U>& r) {
- l.swap(r);
- }
-
- template <typename U>
- static void Assign(TIntrusiveConstPtr<U>& l, TIntrusiveConstPtr<U>& r) {
- l.Swap(r);
- }
- };
-
- public:
- TProtectedValue() = default;
-
- TProtectedValue(T value)
- : Value_(value)
- {
- }
-
- T Get() const {
- with_lock (Lock_) {
- return Value_;
- }
- }
-
- void Set(T o) {
- with_lock (Lock_) {
- TAssignOp::Assign(Value_, o);
- }
- }
-
- private:
- T Value_;
- mutable TAdaptiveLock Lock_;
- };
-}
+#pragma once
+
+#include "api/settings.h"
+#include "tool/settings.h"
+
+#include <util/string/cast.h>
+#include <util/system/spinlock.h>
+
+#include <optional>
+
+namespace NTvmAuth {
+ class TTvmClient;
+}
+
+namespace NTvmAuth::NInternal {
+ class TClientCaningKnife {
+ public:
+ static void StartTvmClientStopping(TTvmClient* c);
+ static bool IsTvmClientStopped(TTvmClient* c);
+ };
+}
+
+namespace NTvmAuth::NUtils {
+ TString ToHex(const TStringBuf s);
+
+ inline NTvmAuth::NTvmApi::TClientSettings::TDstMap ParseDstMap(TStringBuf dsts) {
+ NTvmAuth::NTvmApi::TClientSettings::TDstMap res;
+
+ while (dsts) {
+ TStringBuf pair = dsts.NextTok(';');
+ TStringBuf alias = pair.NextTok(':');
+ res.insert(decltype(res)::value_type(
+ alias,
+ IntFromString<TTvmId, 10>(pair)));
+ }
+
+ return res;
+ }
+
+ inline NTvmAuth::NTvmApi::TClientSettings::TDstVector ParseDstVector(TStringBuf dsts) {
+ NTvmAuth::NTvmApi::TClientSettings::TDstVector res;
+
+ while (dsts) {
+ res.push_back(IntFromString<TTvmId, 10>(dsts.NextTok(';')));
+ }
+
+ return res;
+ }
+
+ bool CheckBbEnvOverriding(EBlackboxEnv original, EBlackboxEnv override) noexcept;
+
+ template <class T>
+ class TProtectedValue {
+ class TAssignOp {
+ public:
+ static void Assign(T& l, const T& r) {
+ l = r;
+ }
+
+ template <typename U>
+ static void Assign(std::shared_ptr<U>& l, std::shared_ptr<U>& r) {
+ l.swap(r);
+ }
+
+ template <typename U>
+ static void Assign(TIntrusiveConstPtr<U>& l, TIntrusiveConstPtr<U>& r) {
+ l.Swap(r);
+ }
+ };
+
+ public:
+ TProtectedValue() = default;
+
+ TProtectedValue(T value)
+ : Value_(value)
+ {
+ }
+
+ T Get() const {
+ with_lock (Lock_) {
+ return Value_;
+ }
+ }
+
+ void Set(T o) {
+ with_lock (Lock_) {
+ TAssignOp::Assign(Value_, o);
+ }
+ }
+
+ private:
+ T Value_;
+ mutable TAdaptiveLock Lock_;
+ };
+}