diff options
author | ivanmorozov <ivanmorozov@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
commit | 464ba3814a83db4f2d5327393b0b6eaf0c86bfd7 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp | |
parent | cba5d9a444e2cfe105f55ccda66cd21d50440017 (diff) | |
download | ydb-464ba3814a83db4f2d5327393b0b6eaf0c86bfd7.tar.gz |
Restoring authorship annotation for <ivanmorozov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
32 files changed, 293 insertions, 293 deletions
diff --git a/library/cpp/balloc/balloc.cpp b/library/cpp/balloc/balloc.cpp index f27ae2ee9a..fab489db4c 100644 --- a/library/cpp/balloc/balloc.cpp +++ b/library/cpp/balloc/balloc.cpp @@ -72,7 +72,7 @@ namespace NBalloc { tls.Mode = Disabled; #endif } - + static void Y_FORCE_INLINE Enable() { tls.Mode = ToBeEnabled; } @@ -278,10 +278,10 @@ extern "C" bool IsOwnedByBalloc(void* ptr) { return NBalloc::IsOwnedByBalloc(ptr); } -extern "C" bool BallocDisabled() { - return NBalloc::IsDisabled(); -} - +extern "C" bool BallocDisabled() { + return NBalloc::IsDisabled(); +} + extern "C" void DisableBalloc() { NBalloc::Disable(); } diff --git a/library/cpp/balloc/malloc-info.cpp b/library/cpp/balloc/malloc-info.cpp index a86edd5a0e..604b1fb145 100644 --- a/library/cpp/balloc/malloc-info.cpp +++ b/library/cpp/balloc/malloc-info.cpp @@ -6,7 +6,7 @@ using namespace NMalloc; extern "C" void DisableBalloc(); extern "C" void EnableBalloc(); -extern "C" bool BallocDisabled(); +extern "C" bool BallocDisabled(); namespace { bool SetAllocParam(const char* name, const char* value) { @@ -21,13 +21,13 @@ namespace { } return false; } - + bool CheckAllocParam(const char* name, bool defaultValue) { - if (strcmp(name, "disable") == 0) { - return BallocDisabled(); - } - return defaultValue; - } + if (strcmp(name, "disable") == 0) { + return BallocDisabled(); + } + return defaultValue; + } } TMallocInfo NMalloc::MallocInfo() { @@ -35,7 +35,7 @@ TMallocInfo NMalloc::MallocInfo() { r.Name = "balloc"; r.SetParam = SetAllocParam; - r.CheckParam = CheckAllocParam; + r.CheckParam = CheckAllocParam; return r; } diff --git a/library/cpp/balloc/optional/operators.cpp b/library/cpp/balloc/optional/operators.cpp index 302302ed89..79f74a5806 100644 --- a/library/cpp/balloc/optional/operators.cpp +++ b/library/cpp/balloc/optional/operators.cpp @@ -1 +1 @@ -#include "operators.h" +#include "operators.h" diff --git a/library/cpp/balloc/optional/operators.h b/library/cpp/balloc/optional/operators.h index 3f9e7f4e35..6107d28a6e 100644 --- a/library/cpp/balloc/optional/operators.h +++ b/library/cpp/balloc/optional/operators.h @@ -1,15 +1,15 @@ -#pragma once - +#pragma once + #include <library/cpp/malloc/api/malloc.h> -#include <util/string/type.h> - -inline bool BallocEnabled() { - return !::NMalloc::MallocInfo().CheckParam("disable", true); -} - -inline void ThreadDisableBalloc() { - ::NMalloc::MallocInfo().SetParam("disable", "true"); -} +#include <util/string/type.h> + +inline bool BallocEnabled() { + return !::NMalloc::MallocInfo().CheckParam("disable", true); +} + +inline void ThreadDisableBalloc() { + ::NMalloc::MallocInfo().SetParam("disable", "true"); +} inline void ThreadEnableBalloc() { ::NMalloc::MallocInfo().SetParam("disable", "false"); diff --git a/library/cpp/balloc/optional/ya.make b/library/cpp/balloc/optional/ya.make index a9fdce993b..f740fc0b7d 100644 --- a/library/cpp/balloc/optional/ya.make +++ b/library/cpp/balloc/optional/ya.make @@ -1,15 +1,15 @@ -LIBRARY() - -OWNER(ivanmorozov) - -SRCS( - operators.cpp -) - -PEERDIR( +LIBRARY() + +OWNER(ivanmorozov) + +SRCS( + operators.cpp +) + +PEERDIR( library/cpp/malloc/api -) - -END() +) + +END() NEED_CHECK() diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index 204c4b7b63..f6951f68cd 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -65,9 +65,9 @@ const char* TBaseServerRequestData::RemoteAddr() const { } const char* TBaseServerRequestData::HeaderIn(TStringBuf key) const { - auto it = HeadersIn_.find(key); + auto it = HeadersIn_.find(key); - if (it == HeadersIn_.end()) { + if (it == HeadersIn_.end()) { return nullptr; } @@ -108,7 +108,7 @@ const char* TBaseServerRequestData::Environment(const char* key) const { } void TBaseServerRequestData::Clear() { - HeadersIn_.clear(); + HeadersIn_.clear(); Addr = Path = Search = nullptr; OrigSearch = {}; SearchLength = 0; @@ -180,7 +180,7 @@ bool TBaseServerRequestData::Parse(const char* origReq) { } void TBaseServerRequestData::AddHeader(const TString& name, const TString& value) { - HeadersIn_[name] = value; + HeadersIn_[name] = value; if (stricmp(name.data(), "Host") == 0) { size_t hostLen = strcspn(value.data(), ":"); @@ -192,5 +192,5 @@ void TBaseServerRequestData::AddHeader(const TString& name, const TString& value void TBaseServerRequestData::SetPath(const TString& path) { PathStorage = TBuffer(path.data(), path.size() + 1); - Path = PathStorage.Data(); + Path = PathStorage.Data(); } diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h index 7fd7745314..16e59c4d78 100644 --- a/library/cpp/http/misc/httpreqdata.h +++ b/library/cpp/http/misc/httpreqdata.h @@ -61,11 +61,11 @@ public: const char* HeaderIn(TStringBuf key) const; const THttpHeadersContainer& HeadersIn() const { - return HeadersIn_; - } - + return HeadersIn_; + } + inline size_t HeadersCount() const noexcept { - return HeadersIn_.size(); + return HeadersIn_.size(); } TString HeaderByIndex(size_t n) const noexcept; @@ -87,7 +87,7 @@ public: void AddHeader(const TString& name, const TString& value); private: - TBuffer PathStorage; + TBuffer PathStorage; mutable char* Addr; TString Host; TString Port; diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 6180660246..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -660,14 +660,14 @@ bool TClientRequest::CheckLoopback() { return true; } -void TClientRequest::ReleaseConnection() { +void TClientRequest::ReleaseConnection() { if (Conn_ && HttpConn_ && HttpServ()->Options().KeepAliveEnabled && HttpConn_->CanBeKeepAlive() && (!HttpServ()->Options().RejectExcessConnections || !HttpServ()->MaxRequestsReached())) { - Output().Finish(); - Conn_->DeActivate(); + Output().Finish(); + Conn_->DeActivate(); Y_UNUSED(Conn_.Release()); - } -} - + } +} + void TClientRequest::ResetConnection() { if (HttpConn_) { // send RST packet to client @@ -706,7 +706,7 @@ void TClientRequest::Process(void* ThreadSpecificResource) { } if (Reply(ThreadSpecificResource)) { - ReleaseConnection(); + ReleaseConnection(); /* * *this will be destroyed... diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index e9e9c71c15..b292d38f27 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -126,7 +126,7 @@ public: bool CheckLoopback(); void ProcessFailRequest(int failstate); - void ReleaseConnection(); + void ReleaseConnection(); void ResetConnection(); diff --git a/library/cpp/json/json_writer.cpp b/library/cpp/json/json_writer.cpp index a6345e0943..3d058bae36 100644 --- a/library/cpp/json/json_writer.cpp +++ b/library/cpp/json/json_writer.cpp @@ -118,22 +118,22 @@ namespace NJson { Buf.WriteJsonValue(v, SortKeys, FloatToStringMode, DoubleNDigits); } - void TJsonWriter::Write(const TJsonValue& v) { - Buf.WriteJsonValue(&v, SortKeys, FloatToStringMode, DoubleNDigits); - } - + void TJsonWriter::Write(const TJsonValue& v) { + Buf.WriteJsonValue(&v, SortKeys, FloatToStringMode, DoubleNDigits); + } + TString WriteJson(const TJsonValue* value, bool formatOutput, bool sortkeys, bool validateUtf8) { TStringStream ss; WriteJson(&ss, value, formatOutput, sortkeys, validateUtf8); return ss.Str(); } - + TString WriteJson(const TJsonValue& value, bool formatOutput, bool sortkeys, bool validateUtf8) { TStringStream ss; WriteJson(&ss, &value, formatOutput, sortkeys, validateUtf8); return ss.Str(); } - + void WriteJson(IOutputStream* out, const TJsonValue* val, bool formatOutput, bool sortkeys, bool validateUtf8) { TJsonWriter w(out, formatOutput, sortkeys, validateUtf8); w.Write(val); diff --git a/library/cpp/json/json_writer.h b/library/cpp/json/json_writer.h index 71b5e4d1d0..c7f5c9499a 100644 --- a/library/cpp/json/json_writer.h +++ b/library/cpp/json/json_writer.h @@ -85,7 +85,7 @@ namespace NJson { void Write(double value); void Write(bool value); void Write(const TJsonValue* value); - void Write(const TJsonValue& value); + void Write(const TJsonValue& value); // must use all variations of integer types since long // and long long are different types but with same size diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp index fe9ae61505..c61e8d1dc4 100644 --- a/library/cpp/json/writer/json_value.cpp +++ b/library/cpp/json/writer/json_value.cpp @@ -9,7 +9,7 @@ #include <util/stream/output.h> #include <util/string/cast.h> #include <util/string/type.h> -#include <util/string/vector.h> +#include <util/string/vector.h> #include <util/system/yassert.h> #include <util/ysaveload.h> #include <util/generic/bt_exception.h> @@ -850,7 +850,7 @@ namespace NJson { } return currentJson; - } + } } // anonymous namespace bool TJsonValue::GetValueByPath(const TStringBuf path, TJsonValue& result, char delimiter) const { @@ -860,8 +860,8 @@ namespace NJson { return true; } return false; - } - + } + bool TJsonValue::SetValueByPath(const TStringBuf path, const TJsonValue& value, char delimiter) { TJsonValue* const ptr = GetValuePtrByPath<true>(this, path, delimiter); if (ptr) { @@ -886,12 +886,12 @@ namespace NJson { TJsonValue* TJsonValue::GetValueByPath(const TStringBuf key, char delim) noexcept { return GetValuePtrByPath<false>(this, key, delim); - } + } void TJsonValue::DoScan(const TString& path, TJsonValue* parent, IScanCallback& callback) { if (!callback.Do(path, parent, *this)) { return; - } + } if (Type == JSON_MAP) { for (auto&& i : *Value.Map) { @@ -901,9 +901,9 @@ namespace NJson { for (ui32 i = 0; i < Value.Array->size(); ++i) { (*Value.Array)[i].DoScan(TString::Join(path, "[", ToString(i), "]"), this, callback); } - } - } - + } + } + void TJsonValue::Scan(IScanCallback& callback) { DoScan("", nullptr, callback); } diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h index b41712c5d6..3f0f50bc4c 100644 --- a/library/cpp/json/writer/json_value.h +++ b/library/cpp/json/writer/json_value.h @@ -27,13 +27,13 @@ namespace NJson { class IScanCallback { public: virtual ~IScanCallback() = default; - + virtual bool Do(const TString& path, TJsonValue* parent, TJsonValue& value) = 0; }; - + class TJsonValue { void Clear() noexcept; - + public: typedef THashMap<TString, TJsonValue> TMapType; typedef TDeque<TJsonValue> TArray; @@ -96,7 +96,7 @@ namespace NJson { // returns NULL on failure const TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') const noexcept; TJsonValue* GetValueByPath(TStringBuf path, char delimiter = '.') noexcept; - + void EraseValue(TStringBuf key); void EraseValue(size_t index); @@ -178,7 +178,7 @@ namespace NJson { /// Non-robust comparison. bool operator==(const TJsonValue& rhs) const; - + bool operator!=(const TJsonValue& rhs) const { return !(*this == rhs); } diff --git a/library/cpp/json/writer/json_value_ut.cpp b/library/cpp/json/writer/json_value_ut.cpp index 40000bd68a..dc7f6affdf 100644 --- a/library/cpp/json/writer/json_value_ut.cpp +++ b/library/cpp/json/writer/json_value_ut.cpp @@ -234,22 +234,22 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { } Y_UNIT_TEST(GetValueByPathTest) { - { - TJsonValue lhs; - TJsonValue first; - TJsonValue second; - TJsonValue last; - first.InsertValue("e", "f"); - second.InsertValue("c", first); - last.InsertValue("a", second); - lhs.InsertValue("l", last); - - TJsonValue result; + { + TJsonValue lhs; + TJsonValue first; + TJsonValue second; + TJsonValue last; + first.InsertValue("e", "f"); + second.InsertValue("c", first); + last.InsertValue("a", second); + lhs.InsertValue("l", last); + + TJsonValue result; UNIT_ASSERT(lhs.GetValueByPath("l/a/c/e", result, '/')); - UNIT_ASSERT(result.GetStringRobust() == "f"); + UNIT_ASSERT(result.GetStringRobust() == "f"); UNIT_ASSERT(!lhs.GetValueByPath("l/a/c/se", result, '/')); UNIT_ASSERT(lhs.GetValueByPath("l/a/c", result, '/')); - UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}"); + UNIT_ASSERT(result.GetStringRobust() == "{\"e\":\"f\"}"); // faster TStringBuf version UNIT_ASSERT_EQUAL(*lhs.GetValueByPath("l", '/'), last); @@ -282,9 +282,9 @@ Y_UNIT_TEST_SUITE(TJsonValueTest) { UNIT_ASSERT(lhs.SetValueByPath("l/a/c/se", "h", '/')); UNIT_ASSERT(lhs.GetValueByPath("l/a/c/se", result, '/')); UNIT_ASSERT(result.GetStringRobust() == "h"); - } - } - + } + } + Y_UNIT_TEST(GetValueByPathConstTest) { TJsonValue lhs; TJsonValue first; diff --git a/library/cpp/lcs/lcs_via_lis.cpp b/library/cpp/lcs/lcs_via_lis.cpp index ee385e84fd..1a52608aed 100644 --- a/library/cpp/lcs/lcs_via_lis.cpp +++ b/library/cpp/lcs/lcs_via_lis.cpp @@ -1 +1 @@ -#include "lcs_via_lis.h" +#include "lcs_via_lis.h" diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index 1db0dc41eb..fd2a906d6f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -1574,7 +1574,7 @@ static Y_FORCE_INLINE void* LFAllocImpl(size_t _nSize) { static Y_FORCE_INLINE void* LFAlloc(size_t _nSize) { void* res = LFAllocImpl(_nSize); #ifdef DBG_FILL_MEMORY - if (FillMemoryOnAllocation && res && (_nSize <= DBG_FILL_MAX_SIZE)) { + if (FillMemoryOnAllocation && res && (_nSize <= DBG_FILL_MAX_SIZE)) { memset(res, 0xcf, _nSize); } #endif @@ -1817,12 +1817,12 @@ static bool LFAlloc_SetParam(const char* param, const char* value) { LB_LIMIT_TOTAL_SIZE = (atoi(value) + N_PAGE_SIZE - 1) / N_PAGE_SIZE; return true; } -#ifdef DBG_FILL_MEMORY - if (!strcmp(param, "FillMemoryOnAllocation")) { - FillMemoryOnAllocation = !strcmp(value, "true"); - return true; - } -#endif +#ifdef DBG_FILL_MEMORY + if (!strcmp(param, "FillMemoryOnAllocation")) { + FillMemoryOnAllocation = !strcmp(value, "true"); + return true; + } +#endif if (!strcmp(param, "TransparentHugePages")) { TransparentHugePages = !strcmp(value, "true"); return true; diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp index e0ea81471d..b26bf5e88c 100644 --- a/library/cpp/logger/backend.cpp +++ b/library/cpp/logger/backend.cpp @@ -1,66 +1,66 @@ #include "backend.h" -#include <util/generic/vector.h> -#include <util/system/mutex.h> -#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/system/mutex.h> +#include <util/generic/singleton.h> #include <util/generic/yexception.h> -namespace { - class TGlobalLogsStorage { - private: +namespace { + class TGlobalLogsStorage { + private: TVector<TLogBackend*> Backends; - TMutex Mutex; + TMutex Mutex; - public: - void Register(TLogBackend* backend) { - TGuard<TMutex> g(Mutex); - Backends.push_back(backend); - } - - void UnRegister(TLogBackend* backend) { - TGuard<TMutex> g(Mutex); - for (ui32 i = 0; i < Backends.size(); ++i) { - if (Backends[i] == backend) { - Backends.erase(Backends.begin() + i); - return; - } - } + public: + void Register(TLogBackend* backend) { + TGuard<TMutex> g(Mutex); + Backends.push_back(backend); + } + + void UnRegister(TLogBackend* backend) { + TGuard<TMutex> g(Mutex); + for (ui32 i = 0; i < Backends.size(); ++i) { + if (Backends[i] == backend) { + Backends.erase(Backends.begin() + i); + return; + } + } Y_FAIL("Incorrect pointer for log backend"); - } - + } + void Reopen(bool flush) { - TGuard<TMutex> g(Mutex); - for (auto& b : Backends) { + TGuard<TMutex> g(Mutex); + for (auto& b : Backends) { if (flush) { b->ReopenLog(); } else { b->ReopenLogNoFlush(); } - } - } - }; -} - + } + } + }; +} + template <> -class TSingletonTraits<TGlobalLogsStorage> { -public: - static const size_t Priority = 50; -}; - +class TSingletonTraits<TGlobalLogsStorage> { +public: + static const size_t Priority = 50; +}; + ELogPriority TLogBackend::FiltrationLevel() const { - return LOG_MAX_PRIORITY; -} - + return LOG_MAX_PRIORITY; +} + TLogBackend::TLogBackend() noexcept { - Singleton<TGlobalLogsStorage>()->Register(this); + Singleton<TGlobalLogsStorage>()->Register(this); } TLogBackend::~TLogBackend() { - Singleton<TGlobalLogsStorage>()->UnRegister(this); + Singleton<TGlobalLogsStorage>()->UnRegister(this); } - + void TLogBackend::ReopenLogNoFlush() { ReopenLog(); -} +} void TLogBackend::ReopenAllBackends(bool flush) { Singleton<TGlobalLogsStorage>()->Reopen(flush); diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h index 791771ced9..d088726d6d 100644 --- a/library/cpp/logger/backend.h +++ b/library/cpp/logger/backend.h @@ -23,7 +23,7 @@ public: virtual void ReopenLogNoFlush(); virtual ELogPriority FiltrationLevel() const; - + static void ReopenAllBackends(bool flush = true); virtual size_t QueueSize() const; diff --git a/library/cpp/logger/filter.cpp b/library/cpp/logger/filter.cpp index 2007e4e56a..300ac6b595 100644 --- a/library/cpp/logger/filter.cpp +++ b/library/cpp/logger/filter.cpp @@ -1 +1 @@ -#include "filter.h" +#include "filter.h" diff --git a/library/cpp/logger/filter.h b/library/cpp/logger/filter.h index 4cc66ff512..9ef83fb58c 100644 --- a/library/cpp/logger/filter.h +++ b/library/cpp/logger/filter.h @@ -1,32 +1,32 @@ -#pragma once +#pragma once -#include "priority.h" -#include "record.h" -#include "backend.h" -#include <util/generic/ptr.h> - -class TFilteredLogBackend: public TLogBackend { +#include "priority.h" +#include "record.h" +#include "backend.h" +#include <util/generic/ptr.h> + +class TFilteredLogBackend: public TLogBackend { THolder<TLogBackend> Backend; ELogPriority Level; -public: +public: TFilteredLogBackend(THolder<TLogBackend>&& t, ELogPriority level = LOG_MAX_PRIORITY) noexcept : Backend(std::move(t)) - , Level(level) - { - } - + , Level(level) + { + } + ELogPriority FiltrationLevel() const override { - return Level; - } - + return Level; + } + void ReopenLog() override { - Backend->ReopenLog(); - } - + Backend->ReopenLog(); + } + void WriteData(const TLogRecord& rec) override { if (rec.Priority <= (ELogPriority)Level) { - Backend->WriteData(rec); - } - } -}; + Backend->WriteData(rec); + } + } +}; diff --git a/library/cpp/logger/global/common.cpp b/library/cpp/logger/global/common.cpp index 844936cebe..4fb05c19b4 100644 --- a/library/cpp/logger/global/common.cpp +++ b/library/cpp/logger/global/common.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include <util/generic/yexception.h> diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h index 52daf1f5be..7dcf650dec 100644 --- a/library/cpp/logger/global/common.h +++ b/library/cpp/logger/global/common.h @@ -12,10 +12,10 @@ #include <library/cpp/logger/log.h> -namespace NLoggingImpl { - const size_t SingletonPriority = 500; -} - +namespace NLoggingImpl { + const size_t SingletonPriority = 500; +} + template <class T> T* CreateDefaultLogger() { return nullptr; @@ -35,15 +35,15 @@ namespace NLoggingImpl { public: inline static bool Usage() { - return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get(); + return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get(); } inline static T* Get() { - return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get(); + return SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Get(); } inline static void Set(T* v) { - SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Reset(v); + SingletonWithPriority<TPtr, SingletonPriority>()->Instance.Reset(v); } }; @@ -62,8 +62,8 @@ public: Y_ASSERT(TLoggerOperator::Usage()); return *TLoggerOperator::Get(); } -}; - +}; + namespace NLoggingImpl { TString GetLocalTimeSSimple(); diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp index 1a9dc8c1c7..9fbd10f666 100644 --- a/library/cpp/logger/global/global.cpp +++ b/library/cpp/logger/global/global.cpp @@ -1,12 +1,12 @@ -#include "global.h" - +#include "global.h" + static void DoInitGlobalLog(THolder<TGlobalLog> logger, THolder<ILoggerFormatter> formatter) { TLoggerOperator<TGlobalLog>::Set(logger.Release()); if (!formatter) { formatter.Reset(CreateRtyLoggerFormatter()); } TLoggerFormatterOperator::Set(formatter.Release()); -} +} void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter, bool threaded) { DoInitGlobalLog( @@ -35,9 +35,9 @@ template <> TNullLog* CreateDefaultLogger<TNullLog>() { return new TNullLog("null"); } - -NPrivateGlobalLogger::TVerifyEvent::~TVerifyEvent() { - const TString info = Str(); - FATAL_LOG << info << Endl; + +NPrivateGlobalLogger::TVerifyEvent::~TVerifyEvent() { + const TString info = Str(); + FATAL_LOG << info << Endl; Y_FAIL("%s", info.data()); -} +} diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h index 0692b79c9a..cbe71b16ea 100644 --- a/library/cpp/logger/global/global.h +++ b/library/cpp/logger/global/global.h @@ -1,26 +1,26 @@ -#pragma once - -#include "common.h" +#pragma once + +#include "common.h" #include "rty_formater.h" - -// ATTENTION! MUST CALL DoInitGlobalLog BEFORE USAGE - + +// ATTENTION! MUST CALL DoInitGlobalLog BEFORE USAGE + bool GlobalLogInitialized(); void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rotation, const bool startAsDaemon, THolder<ILoggerFormatter> formatter = {}, bool threaded = false); void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter = {}); - -inline void InitGlobalLog2Null() { + +inline void InitGlobalLog2Null() { DoInitGlobalLog("null", TLOG_EMERG, false, false); -} - -inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) { - DoInitGlobalLog("console", loglevel, false, false); -} - -class TGlobalLog: public TLog { -public: +} + +inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) { + DoInitGlobalLog("console", loglevel, false, false); +} + +class TGlobalLog: public TLog { +public: TGlobalLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY) - : TLog(logType, priority) + : TLog(logType, priority) { } @@ -28,15 +28,15 @@ public: : TLog(std::move(backend)) { } -}; - +}; + template <> TGlobalLog* CreateDefaultLogger<TGlobalLog>(); -class TNullLog: public TLog { -public: +class TNullLog: public TLog { +public: TNullLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY) - : TLog(logType, priority) + : TLog(logType, priority) { } @@ -44,8 +44,8 @@ public: : TLog(std::move(backend)) { } -}; - +}; + template <> TNullLog* CreateDefaultLogger<TNullLog>(); @@ -62,21 +62,21 @@ public: }; #define FATAL_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_CRIT, "CRITICAL_INFO") -#define ALERT_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_ALERT, "ALERT") +#define ALERT_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_ALERT, "ALERT") #define ERROR_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_ERR, "ERROR") #define WARNING_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_WARNING, "WARNING") #define NOTICE_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_NOTICE, "NOTICE") #define INFO_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_INFO, "INFO") #define DEBUG_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_DEBUG, "DEBUG") #define RESOURCES_LOG SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, TLOG_RESOURCES, "RESOURCES") - + #define TEMPLATE_LOG(logLevel) SINGLETON_CHECKED_GENERIC_LOG(TGlobalLog, TRTYLogPreprocessor, logLevel, ToString(logLevel).data()) -#define IS_LOG_ACTIVE(logLevel) (TLoggerOperator<TGlobalLog>::Log().FiltrationLevel() >= logLevel) - +#define IS_LOG_ACTIVE(logLevel) (TLoggerOperator<TGlobalLog>::Log().FiltrationLevel() >= logLevel) + #define RTY_MEM_LOG(Action) \ { NOTICE_LOG << "RESOURCES On " << Action << ": " << NLoggingImpl::GetSystemResources() << Endl; }; - + #define VERIFY_WITH_LOG(expr, msg, ...) \ do { \ if (Y_UNLIKELY(!(expr))) { \ @@ -84,42 +84,42 @@ public: Y_VERIFY(false, msg, ##__VA_ARGS__); \ }; \ } while (0); - -namespace NPrivateGlobalLogger { - class TVerifyEvent: public TStringStream { - public: - ~TVerifyEvent(); - template <class T> + +namespace NPrivateGlobalLogger { + class TVerifyEvent: public TStringStream { + public: + ~TVerifyEvent(); + template <class T> inline TVerifyEvent& operator<<(const T& t) { static_cast<IOutputStream&>(*this) << t; - - return *this; - } - }; - class TNullStream: public TStringStream { - public: - ~TNullStream() = default; - - template <class T> - inline TNullStream& operator<<(const T& /*t*/) { - return *this; - } - }; -} - -#define CHECK_WITH_LOG(expr) \ - Y_UNLIKELY(!(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TVerifyEvent() << __LOCATION__ << ": " << #expr << "(verification failed!): " - -#if !defined(NDEBUG) && !defined(__GCCXML__) -#define ASSERT_WITH_LOG(expr) \ - Y_UNLIKELY(!(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TVerifyEvent() << __LOCATION__ << ": " << #expr << "(verification failed!): " -#else -#define ASSERT_WITH_LOG(expr) \ - Y_UNLIKELY(false && !(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TNullStream() -#endif - -#define CHECK_EQ_WITH_LOG(a, b) CHECK_WITH_LOG((a) == (b)) << a << " != " << b; -#define CHECK_LEQ_WITH_LOG(a, b) CHECK_WITH_LOG((a) <= (b)) << a << " > " << b; - + + return *this; + } + }; + class TNullStream: public TStringStream { + public: + ~TNullStream() = default; + + template <class T> + inline TNullStream& operator<<(const T& /*t*/) { + return *this; + } + }; +} + +#define CHECK_WITH_LOG(expr) \ + Y_UNLIKELY(!(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TVerifyEvent() << __LOCATION__ << ": " << #expr << "(verification failed!): " + +#if !defined(NDEBUG) && !defined(__GCCXML__) +#define ASSERT_WITH_LOG(expr) \ + Y_UNLIKELY(!(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TVerifyEvent() << __LOCATION__ << ": " << #expr << "(verification failed!): " +#else +#define ASSERT_WITH_LOG(expr) \ + Y_UNLIKELY(false && !(expr)) && NPrivateGlobalLogger::TEatStream() | NPrivateGlobalLogger::TNullStream() +#endif + +#define CHECK_EQ_WITH_LOG(a, b) CHECK_WITH_LOG((a) == (b)) << a << " != " << b; +#define CHECK_LEQ_WITH_LOG(a, b) CHECK_WITH_LOG((a) <= (b)) << a << " > " << b; + #define FAIL_LOG(msg, ...) VERIFY_WITH_LOG(false, msg, ##__VA_ARGS__) -#define S_FAIL_LOG CHECK_WITH_LOG(false) +#define S_FAIL_LOG CHECK_WITH_LOG(false) diff --git a/library/cpp/logger/global/ya.make b/library/cpp/logger/global/ya.make index 843f01016c..20eb361e72 100644 --- a/library/cpp/logger/global/ya.make +++ b/library/cpp/logger/global/ya.make @@ -6,10 +6,10 @@ PEERDIR( library/cpp/logger ) -IF (OS_WINDOWS) - NO_WERROR() -ENDIF() - +IF (OS_WINDOWS) + NO_WERROR() +ENDIF() + SRCS( common.cpp global.cpp diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp index 23bfea0e0c..e1d70cc3d2 100644 --- a/library/cpp/logger/log.cpp +++ b/library/cpp/logger/log.cpp @@ -101,13 +101,13 @@ public: inline void WriteData(ELogPriority priority, const char* data, size_t len) const { if (IsOpen()) { Backend_->WriteData(TLogRecord(priority, data, len)); - } + } } - + inline ELogPriority DefaultPriority() noexcept { return DefaultPriority_; } - + inline void SetDefaultPriority(ELogPriority priority) noexcept { DefaultPriority_ = priority; } @@ -197,9 +197,9 @@ void TLog::SetDefaultPriority(ELogPriority priority) noexcept { } ELogPriority TLog::FiltrationLevel() const noexcept { - return Impl_->FiltrationLevel(); -} - + return Impl_->FiltrationLevel(); +} + ELogPriority TLog::DefaultPriority() const noexcept { return Impl_->DefaultPriority(); } diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index 09ab9ba1a5..8be984ccc8 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -85,7 +85,7 @@ public: // Call `FiltrationLevel()` of the underlying backend. ELogPriority FiltrationLevel() const noexcept; - + // Set current log formatter. void SetFormatter(TLogFormatter formatter) noexcept; diff --git a/library/cpp/malloc/api/malloc.cpp b/library/cpp/malloc/api/malloc.cpp index c417c3bb74..eed1c58a38 100644 --- a/library/cpp/malloc/api/malloc.cpp +++ b/library/cpp/malloc/api/malloc.cpp @@ -13,10 +13,10 @@ namespace { } bool CheckEmptyParam(const char*, bool defaultValue) { - return defaultValue; - } + return defaultValue; + } } - + namespace NMalloc { volatile bool IsAllocatorCorrupted = false; @@ -24,7 +24,7 @@ namespace NMalloc { : Name() , SetParam(SetEmptyParam) , GetParam(GetEmptyParam) - , CheckParam(CheckEmptyParam) + , CheckParam(CheckEmptyParam) { } diff --git a/library/cpp/malloc/api/malloc.h b/library/cpp/malloc/api/malloc.h index f6aa9b9640..ebd545d6dd 100644 --- a/library/cpp/malloc/api/malloc.h +++ b/library/cpp/malloc/api/malloc.h @@ -12,7 +12,7 @@ namespace NMalloc { bool (*SetParam)(const char* param, const char* value); const char* (*GetParam)(const char* param); - bool (*CheckParam)(const char* param, bool defaultValue); + bool (*CheckParam)(const char* param, bool defaultValue); }; extern volatile bool IsAllocatorCorrupted; diff --git a/library/cpp/messagebus/scheduler/scheduler.cpp b/library/cpp/messagebus/scheduler/scheduler.cpp index 7ed8576e27..5a5fe52894 100644 --- a/library/cpp/messagebus/scheduler/scheduler.cpp +++ b/library/cpp/messagebus/scheduler/scheduler.cpp @@ -26,11 +26,11 @@ TScheduler::~TScheduler() { Y_VERIFY(StopThread, "state check"); } -size_t TScheduler::Size() const { - TGuard<TLock> guard(Lock); - return Items.size() + (!!NextItem ? 1 : 0); -} - +size_t TScheduler::Size() const { + TGuard<TLock> guard(Lock); + return Items.size() + (!!NextItem ? 1 : 0); +} + void TScheduler::Stop() { { TGuard<TLock> guard(Lock); @@ -39,11 +39,11 @@ void TScheduler::Stop() { CondVar.Signal(); } Thread.Get(); - - if (!!NextItem) { - NextItem.Destroy(); - } - + + if (!!NextItem) { + NextItem.Destroy(); + } + for (auto& item : Items) { item.Destroy(); } @@ -105,7 +105,7 @@ void TScheduler::SchedulerThread() { continue; } - current = NextItem.Release(); + current = NextItem.Release(); } current->Do(); diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 82085e0929..96cc11bcfd 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -38,7 +38,7 @@ namespace NObjectFactory { return new TDerivedProduct(std::forward<TArgs>(args)...); } }; - + template <class TBaseProduct, class TDerivedProduct> class TFactoryObjectCreator<TBaseProduct, TDerivedProduct, void>: public IFactoryObjectCreator<TBaseProduct, void> { TDerivedProduct* Create() const override { @@ -82,12 +82,12 @@ namespace NObjectFactory { typename ICreators::const_iterator i = Creators.find(key); return i == Creators.end() ? nullptr : i->second.Get(); } - + bool HasImpl(const TKey& key) const { TReadGuard guard(CreatorsLock); return Creators.find(key) != Creators.end(); } - + private: typedef TSimpleSharedPtr<IFactoryObjectCreator<TProduct, TArgs...>> ICreatorPtr; typedef TMap<TKey, ICreatorPtr> ICreators; @@ -119,8 +119,8 @@ namespace NObjectFactory { result = Singleton<TObjectFactory<TProduct, TKey>>()->Create(defKey); } return result; - } - + } + static TProduct* Construct(const TKey& key) { TProduct* result = Singleton<TObjectFactory<TProduct, TKey>>()->Create(key); return result; @@ -139,8 +139,8 @@ namespace NObjectFactory { static bool Has(const TKey& key) { return Singleton<TObjectFactory<TProduct, TKey>>()->HasImpl(key); - } - + } + static void GetRegisteredKeys(TSet<TKey>& keys) { return Singleton<TObjectFactory<TProduct, TKey>>()->GetKeys(keys); } @@ -168,7 +168,7 @@ namespace NObjectFactory { TRegistrator(const TKey& key, IFactoryObjectCreator<TProduct, void>* creator) { Singleton<TObjectFactory<TProduct, TKey>>()->template Register<Product>(key, creator); } - + TRegistrator(const TKey& key) { Singleton<TObjectFactory<TProduct, TKey>>()->template Register<Product>(key); } @@ -179,7 +179,7 @@ namespace NObjectFactory { } }; }; - + template <class TProduct, class TKey, class... TArgs> class TParametrizedObjectFactory: public IObjectFactory<TProduct, TKey, TArgs...> { public: @@ -190,7 +190,7 @@ namespace NObjectFactory { static bool Has(const TKey& key) { return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->HasImpl(key); - } + } static TProduct* Construct(const TKey& key, TArgs... args) { return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->Create(key, std::forward<TArgs>(args)...); @@ -224,7 +224,7 @@ namespace NObjectFactory { TRegistrator(const TKey& key, IFactoryObjectCreator<TProduct, TArgs...>* creator) { Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->template Register<Product>(key, creator); } - + TRegistrator(const TKey& key) { Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->template Register<Product>(key); } @@ -233,10 +233,10 @@ namespace NObjectFactory { : TRegistrator(Product::GetTypeName()) { } - - TString GetName() const { - return Product::GetTypeName(); - } + + TString GetName() const { + return Product::GetTypeName(); + } }; }; diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 8d9d671351..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -358,7 +358,7 @@ namespace NUnicode { //! decompose utf16 or utf32 string to any container supporting push_back or to T* template <NUnicode::ENormalization Norm, class T, typename TCharType> inline void Normalize(const TCharType* begin, size_t len, T& out) { - ::NUnicode::TNormalizer<Norm> dec; + ::NUnicode::TNormalizer<Norm> dec; dec.Normalize(begin, len, out); } @@ -374,7 +374,7 @@ inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { template <NUnicode::ENormalization N, typename TCharType> inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { - ::NUnicode::TNormalizer<N> dec; + ::NUnicode::TNormalizer<N> dec; return dec.Normalize(str); } |