diff options
author | asorotsky <asorotsky@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
commit | 80f0a6b4102e3b2c89f23935c7690409033ea24c (patch) | |
tree | d37ae19cf2360516f71e010c02f3fd8fc6b22999 /library | |
parent | 9f1d4466bb653173233b0e47d2cbda7f46995f92 (diff) | |
download | ydb-80f0a6b4102e3b2c89f23935c7690409033ea24c.tar.gz |
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
43 files changed, 273 insertions, 273 deletions
diff --git a/library/cpp/actors/core/event_local.h b/library/cpp/actors/core/event_local.h index 2845aa94dd..a197a7c9d7 100644 --- a/library/cpp/actors/core/event_local.h +++ b/library/cpp/actors/core/event_local.h @@ -9,7 +9,7 @@ namespace NActors { template <typename TEv, ui32 TEventType> class TEventLocal: public TEventBase<TEv, TEventType> { public: - TString ToStringHeader() const override { + TString ToStringHeader() const override { return TypeName<TEv>(); } @@ -17,7 +17,7 @@ namespace NActors { Y_FAIL("Serialization of local event %s type %" PRIu32, TypeName<TEv>().data(), TEventType); } - bool IsSerializable() const override { + bool IsSerializable() const override { return false; } diff --git a/library/cpp/actors/core/event_pb.h b/library/cpp/actors/core/event_pb.h index d7546b901a..32e93fef8a 100644 --- a/library/cpp/actors/core/event_pb.h +++ b/library/cpp/actors/core/event_pb.h @@ -88,19 +88,19 @@ namespace NActors { return Event; } - bool Next(void** data, int* size) override; - void BackUp(int count) override; + bool Next(void** data, int* size) override; + void BackUp(int count) override; int64_t ByteCount() const override { return TotalSerializedDataSize; } - bool WriteAliasedRaw(const void* data, int size) override; - bool AllowsAliasing() const override; + bool WriteAliasedRaw(const void* data, int size) override; + bool AllowsAliasing() const override; bool WriteRope(const TRope *rope) override; bool WriteString(const TString *s) override; protected: - void DoRun() override; + void DoRun() override; void Resume(); bool Produce(const void *data, size_t size); diff --git a/library/cpp/actors/core/executor_pool_basic.h b/library/cpp/actors/core/executor_pool_basic.h index 023190f7fe..9c089bcee6 100644 --- a/library/cpp/actors/core/executor_pool_basic.h +++ b/library/cpp/actors/core/executor_pool_basic.h @@ -58,7 +58,7 @@ namespace NActors { const ui32 EventsPerMailbox; const int RealtimePriority; - + TAtomic ThreadUtilization; TAtomic MaxUtilizationCounter; TAtomic MaxUtilizationAccumulator; diff --git a/library/cpp/actors/core/executor_pool_io.h b/library/cpp/actors/core/executor_pool_io.h index e576d642a1..03ed4288d3 100644 --- a/library/cpp/actors/core/executor_pool_io.h +++ b/library/cpp/actors/core/executor_pool_io.h @@ -23,13 +23,13 @@ namespace NActors { TTicketLock ScheduleLock; const TString PoolName; - + public: TIOExecutorPool(ui32 poolId, ui32 threads, const TString& poolName = "", TAffinity* affinity = nullptr, ui32 maxActivityType = 1); explicit TIOExecutorPool(const TIOExecutorPoolConfig& cfg); ~TIOExecutorPool(); - + ui32 GetReadyActivation(TWorkerContext& wctx, ui64 revolvingCounter) override; void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) override; diff --git a/library/cpp/actors/core/executor_pool_united.h b/library/cpp/actors/core/executor_pool_united.h index a090ba2466..fa8e4f0391 100644 --- a/library/cpp/actors/core/executor_pool_united.h +++ b/library/cpp/actors/core/executor_pool_united.h @@ -60,7 +60,7 @@ namespace NActors { // Returns per worker schedule writers NSchedulerQueue::TWriter* GetScheduleWriter(TWorkerId workerId) const; - + // Sets executor for specified pool void SetupPool(TPoolId pool, IExecutorPool* executorPool, TMailboxTable* mailboxTable); diff --git a/library/cpp/actors/core/executor_thread.h b/library/cpp/actors/core/executor_thread.h index 9d3c573f0d..1dc8b315e0 100644 --- a/library/cpp/actors/core/executor_thread.h +++ b/library/cpp/actors/core/executor_thread.h @@ -83,7 +83,7 @@ namespace NActors { TVector<THolder<IActor>> DyingActors; TActorId CurrentRecipient; ui64 CurrentActorScheduledEventsCounter = 0; - + // Thread-specific TWorkerContext Ctx; ui64 RevolvingReadCounter = 0; diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp index f52f2fc5d2..75fa1a1dd6 100644 --- a/library/cpp/actors/core/log_settings.cpp +++ b/library/cpp/actors/core/log_settings.cpp @@ -49,34 +49,34 @@ namespace NActors { } void TSettings::Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func) { - Y_VERIFY(minVal >= 0, "NLog::TSettings: minVal must be non-negative"); + Y_VERIFY(minVal >= 0, "NLog::TSettings: minVal must be non-negative"); Y_VERIFY(maxVal > minVal, "NLog::TSettings: maxVal must be greater than minVal"); // update bounds - if (!MaxVal || minVal < MinVal) { - MinVal = minVal; - } + if (!MaxVal || minVal < MinVal) { + MinVal = minVal; + } if (!MaxVal || maxVal > MaxVal) { - MaxVal = maxVal; - + MaxVal = maxVal; + // expand ComponentNames to the new bounds - auto oldMask = Mask; - Mask = PowerOf2Mask(MaxVal); - - TArrayHolder<TAtomic> oldComponentInfo(new TAtomic[Mask + 1]); - ComponentInfo.Swap(oldComponentInfo); - int startVal = oldMask ? oldMask + 1 : 0; - for (int i = 0; i < startVal; i++) { - AtomicSet(ComponentInfo[i], AtomicGet(oldComponentInfo[i])); - } - - TComponentSettings defSetting(DefPriority, DefSamplingPriority, DefSamplingRate); - for (int i = startVal; i < Mask + 1; i++) { - AtomicSet(ComponentInfo[i], defSetting.Raw.Data); - } - - ComponentNames.resize(Mask + 1); + auto oldMask = Mask; + Mask = PowerOf2Mask(MaxVal); + + TArrayHolder<TAtomic> oldComponentInfo(new TAtomic[Mask + 1]); + ComponentInfo.Swap(oldComponentInfo); + int startVal = oldMask ? oldMask + 1 : 0; + for (int i = 0; i < startVal; i++) { + AtomicSet(ComponentInfo[i], AtomicGet(oldComponentInfo[i])); + } + + TComponentSettings defSetting(DefPriority, DefSamplingPriority, DefSamplingRate); + for (int i = startVal; i < Mask + 1; i++) { + AtomicSet(ComponentInfo[i], defSetting.Raw.Data); + } + + ComponentNames.resize(Mask + 1); } // assign new names but validate if newly added members were not used before diff --git a/library/cpp/actors/core/scheduler_basic.cpp b/library/cpp/actors/core/scheduler_basic.cpp index fba200e16b..3cb40546ae 100644 --- a/library/cpp/actors/core/scheduler_basic.cpp +++ b/library/cpp/actors/core/scheduler_basic.cpp @@ -7,7 +7,7 @@ #ifdef BALLOC #include <library/cpp/balloc/optional/operators.h> #endif - + namespace NActors { struct TBasicSchedulerThread::TMonCounters { @@ -57,7 +57,7 @@ namespace NActors { ui64 currentMonotonic = RelaxedLoad(CurrentMonotonic); ui64 throttledMonotonic = currentMonotonic; - + ui64 activeTick = AlignUp<ui64>(throttledMonotonic, IntrasecondThreshold); TAutoPtr<TMomentMap> activeSec; diff --git a/library/cpp/actors/helpers/future_callback.h b/library/cpp/actors/helpers/future_callback.h index 8ca0d99fda..ae8fe045c3 100644 --- a/library/cpp/actors/helpers/future_callback.h +++ b/library/cpp/actors/helpers/future_callback.h @@ -1,7 +1,7 @@ #pragma once #include <library/cpp/actors/core/actor.h> -#include <library/cpp/actors/core/hfunc.h> +#include <library/cpp/actors/core/hfunc.h> namespace NActors { diff --git a/library/cpp/actors/memory_log/memlog.h b/library/cpp/actors/memory_log/memlog.h index 2aa27272a6..a16d694ba2 100644 --- a/library/cpp/actors/memory_log/memlog.h +++ b/library/cpp/actors/memory_log/memlog.h @@ -45,7 +45,7 @@ public: return AtomicGet(MemLogBuffer); } - void* GetWriteBuffer(size_t amount) noexcept; + void* GetWriteBuffer(size_t amount) noexcept; inline static void* GetWriteBufferStatic(size_t amount) noexcept { auto logger = GetMemoryLogger(); @@ -62,7 +62,7 @@ public: inline static void CreateMemoryLogBuffer( size_t totalSize = DEFAULT_TOTAL_SIZE, size_t grainSize = DEFAULT_GRAIN_SIZE) - Y_COLD { + Y_COLD { if (AtomicGet(MemLogBuffer) != nullptr) { return; } @@ -73,7 +73,7 @@ public: static std::atomic<bool> PrintLastMark; // buffer must be at least 16 bytes - static void ChangeLastMark(char* buffer) noexcept; + static void ChangeLastMark(char* buffer) noexcept; inline static TThread::TId GetTheadId() noexcept { if (LogThreadId == 0) { @@ -83,7 +83,7 @@ public: } private: - TMemoryLog(size_t totalSize, size_t grainSize) Y_COLD; + TMemoryLog(size_t totalSize, size_t grainSize) Y_COLD; struct TGrain { TAtomic WritePointer = 0; @@ -170,12 +170,12 @@ private: // it's no use of sanitizing this function NO_SANITIZE_THREAD -char* BareMemLogWrite( +char* BareMemLogWrite( const char* begin, size_t msgSize, bool isLast = true) noexcept; // it's no use of sanitizing this function NO_SANITIZE_THREAD -bool MemLogWrite( +bool MemLogWrite( const char* begin, size_t msgSize, bool addLF = false) noexcept; Y_WRAPPER inline bool MemLogWrite(const char* begin, const char* end) noexcept { diff --git a/library/cpp/actors/util/thread.h b/library/cpp/actors/util/thread.h index d742c8c585..c3b0c62356 100644 --- a/library/cpp/actors/util/thread.h +++ b/library/cpp/actors/util/thread.h @@ -1,26 +1,26 @@ -#pragma once - -#include <util/generic/strbuf.h> -#include <util/stream/str.h> -#include <util/system/execpath.h> -#include <util/system/thread.h> -#include <util/system/thread.h> +#pragma once + +#include <util/generic/strbuf.h> +#include <util/stream/str.h> +#include <util/system/execpath.h> +#include <util/system/thread.h> +#include <util/system/thread.h> #include <time.h> - + inline void SetCurrentThreadName(const TString& name, const ui32 maxCharsFromProcessName = 8) { -#if defined(_linux_) +#if defined(_linux_) // linux limits threadname by 15 + \0 TStringBuf procName(GetExecPath()); procName = procName.RNextTok('/'); procName = procName.SubStr(0, maxCharsFromProcessName); - TStringStream linuxName; + TStringStream linuxName; linuxName << procName << "." << name; TThread::SetCurrentThreadName(linuxName.Str().data()); -#else +#else Y_UNUSED(maxCharsFromProcessName); TThread::SetCurrentThreadName(name.data()); -#endif -} +#endif +} diff --git a/library/cpp/lfalloc/alloc_profiler/align_ut.cpp b/library/cpp/lfalloc/alloc_profiler/align_ut.cpp index db9b17b95b..1b62fe73b7 100644 --- a/library/cpp/lfalloc/alloc_profiler/align_ut.cpp +++ b/library/cpp/lfalloc/alloc_profiler/align_ut.cpp @@ -1,23 +1,23 @@ -#include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/scope.h> - -Y_UNIT_TEST_SUITE(MemAlign) { - Y_UNIT_TEST(ShouldAlign) - { - for (ui64 size = 8; size <= 32 * 1024; size *= 8) { - for (ui64 align = 8; align <= 4096; align *=2) { - void* ptr = nullptr; - - int res = posix_memalign(&ptr, align, size); - UNIT_ASSERT_C(res == 0 && ptr != nullptr, "memalign failed"); - - Y_DEFER { - free(ptr); - }; - - UNIT_ASSERT_C((uintptr_t)ptr % align == 0, "non aligned memory"); - } - } - } -} +#include <library/cpp/testing/unittest/registar.h> + +#include <util/generic/scope.h> + +Y_UNIT_TEST_SUITE(MemAlign) { + Y_UNIT_TEST(ShouldAlign) + { + for (ui64 size = 8; size <= 32 * 1024; size *= 8) { + for (ui64 align = 8; align <= 4096; align *=2) { + void* ptr = nullptr; + + int res = posix_memalign(&ptr, align, size); + UNIT_ASSERT_C(res == 0 && ptr != nullptr, "memalign failed"); + + Y_DEFER { + free(ptr); + }; + + UNIT_ASSERT_C((uintptr_t)ptr % align == 0, "non aligned memory"); + } + } + } +} diff --git a/library/cpp/lfalloc/alloc_profiler/profiler.cpp b/library/cpp/lfalloc/alloc_profiler/profiler.cpp index 0e30927a5a..b4f92fe0db 100644 --- a/library/cpp/lfalloc/alloc_profiler/profiler.cpp +++ b/library/cpp/lfalloc/alloc_profiler/profiler.cpp @@ -1,5 +1,5 @@ #include "profiler.h" - + #include "stackcollect.h" #include <util/generic/algorithm.h> diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp index fded4e2fd1..643fd1ccda 100644 --- a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp +++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp @@ -1,5 +1,5 @@ #include "stackcollect.h" - + #include "profiler.h" #include <util/generic/algorithm.h> diff --git a/library/cpp/lfalloc/alloc_profiler/ut/ya.make b/library/cpp/lfalloc/alloc_profiler/ut/ya.make index 8a7daa74af..9b93752823 100644 --- a/library/cpp/lfalloc/alloc_profiler/ut/ya.make +++ b/library/cpp/lfalloc/alloc_profiler/ut/ya.make @@ -16,7 +16,7 @@ ENDIF() SRCS( profiler_ut.cpp - align_ut.cpp + align_ut.cpp ) END() diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index fd2a906d6f..70f3758ebf 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -1089,7 +1089,7 @@ struct TLocalPerTagAllocCounter { }; static const int DBG_ALLOC_MAX_TAG = 1000; -static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000; +static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000; static const int DBG_ALLOC_NUM_SIZES = 30; static TPerTagAllocCounter GlobalPerTagAllocCounters[DBG_ALLOC_MAX_TAG][DBG_ALLOC_NUM_SIZES]; @@ -1307,25 +1307,25 @@ static void AllocThreadInfo() { #if defined(LFALLOC_DBG) struct TAllocHeader { - uint64_t Size; + uint64_t Size; int Tag; int Cookie; }; -// should be power of 2 -static_assert(sizeof(TAllocHeader) == 16); - +// should be power of 2 +static_assert(sizeof(TAllocHeader) == 16); + static inline void* GetAllocPtr(TAllocHeader* p) { return p + 1; } static inline TAllocHeader* GetAllocHeader(void* p) { - auto* header = ((TAllocHeader*)p) - 1; - if (header->Tag == DBG_ALLOC_ALIGNED_TAG) { - return (TAllocHeader*)header->Size; - } - - return header; + auto* header = ((TAllocHeader*)p) - 1; + if (header->Tag == DBG_ALLOC_ALIGNED_TAG) { + return (TAllocHeader*)header->Size; + } + + return header; } PERTHREAD int AllocationTag; @@ -1882,45 +1882,45 @@ static Y_FORCE_INLINE int LFPosixMemalign(void** memptr, size_t alignment, size_ } else if (bigsize < 2 * alignment) { bigsize = 2 * alignment; } -#if defined(LFALLOC_DBG) - if (alignment > sizeof(TAllocHeader)) { - bigsize += alignment; - } -#endif - +#if defined(LFALLOC_DBG) + if (alignment > sizeof(TAllocHeader)) { + bigsize += alignment; + } +#endif + *memptr = LFAlloc(bigsize); - -#if defined(LFALLOC_DBG) - if (alignment > sizeof(TAllocHeader)) { - // memptr isn't aligned due to alloc header - const auto* header = GetAllocHeader(*memptr); - *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader)); - - // make fake header to retrieve original header ptr on dealloc - auto* next = GetAllocHeader(*memptr); - next->Tag = DBG_ALLOC_ALIGNED_TAG; - next->Size = (uint64_t)header; - next->Cookie = 0; - } -#endif - - Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0); + +#if defined(LFALLOC_DBG) + if (alignment > sizeof(TAllocHeader)) { + // memptr isn't aligned due to alloc header + const auto* header = GetAllocHeader(*memptr); + *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader)); + + // make fake header to retrieve original header ptr on dealloc + auto* next = GetAllocHeader(*memptr); + next->Tag = DBG_ALLOC_ALIGNED_TAG; + next->Size = (uint64_t)header; + next->Cookie = 0; + } +#endif + + Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0); return 0; } - -static Y_FORCE_INLINE void* LFVAlloc(size_t size) { - const size_t pg = N_PAGE_SIZE; - void* p = nullptr; - -#if defined(LFALLOC_DBG) - LFPosixMemalign(&p, pg, size); -#else - size_t bigsize = (size + pg - 1) & (~(pg - 1)); - p = LFAlloc(bigsize); -#endif - - Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0); - return p; -} - -#endif + +static Y_FORCE_INLINE void* LFVAlloc(size_t size) { + const size_t pg = N_PAGE_SIZE; + void* p = nullptr; + +#if defined(LFALLOC_DBG) + LFPosixMemalign(&p, pg, size); +#else + size_t bigsize = (size + pg - 1) & (~(pg - 1)); + p = LFAlloc(bigsize); +#endif + + Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0); + return p; +} + +#endif diff --git a/library/cpp/lwtrace/all.h b/library/cpp/lwtrace/all.h index d7aa57c49d..b02925c44b 100644 --- a/library/cpp/lwtrace/all.h +++ b/library/cpp/lwtrace/all.h @@ -2,7 +2,7 @@ #include "control.h" #include "event.h" -#include "preprocessor.h" +#include "preprocessor.h" #include "probe.h" #include "start.h" diff --git a/library/cpp/lwtrace/check.cpp b/library/cpp/lwtrace/check.cpp index 4e34fc5d49..2fa7c7bc22 100644 --- a/library/cpp/lwtrace/check.cpp +++ b/library/cpp/lwtrace/check.cpp @@ -1,6 +1,6 @@ #include "check.h" - -#include <util/stream/output.h> + +#include <util/stream/output.h> #include <util/string/cast.h> namespace NLWTrace { diff --git a/library/cpp/lwtrace/control.h b/library/cpp/lwtrace/control.h index 16b24eafd2..8f4393b64e 100644 --- a/library/cpp/lwtrace/control.h +++ b/library/cpp/lwtrace/control.h @@ -1,15 +1,15 @@ #pragma once -#include "custom_action.h" -#include "event.h" -#include "log.h" +#include "custom_action.h" +#include "event.h" +#include "log.h" #include "log_shuttle.h" -#include "probe.h" - +#include "probe.h" + #include <library/cpp/lwtrace/protos/lwtrace.pb.h> - + #include <google/protobuf/repeated_field.h> - + #include <util/generic/deque.h> #include <util/generic/hash.h> #include <util/generic/noncopyable.h> diff --git a/library/cpp/lwtrace/custom_action.cpp b/library/cpp/lwtrace/custom_action.cpp index a379b34ec0..bfe07b4fbd 100644 --- a/library/cpp/lwtrace/custom_action.cpp +++ b/library/cpp/lwtrace/custom_action.cpp @@ -1,5 +1,5 @@ #include "custom_action.h" - + #include "control.h" using namespace NLWTrace; diff --git a/library/cpp/lwtrace/custom_action.h b/library/cpp/lwtrace/custom_action.h index 92a3c66b84..3744d4c586 100644 --- a/library/cpp/lwtrace/custom_action.h +++ b/library/cpp/lwtrace/custom_action.h @@ -1,13 +1,13 @@ #pragma once #include "probe.h" - + #include <library/cpp/lwtrace/protos/lwtrace.pb.h> -#include <util/generic/hash.h> - -#include <functional> - +#include <util/generic/hash.h> + +#include <functional> + namespace NLWTrace { class TSession; diff --git a/library/cpp/lwtrace/event.h b/library/cpp/lwtrace/event.h index e53a620c45..0d81f92475 100644 --- a/library/cpp/lwtrace/event.h +++ b/library/cpp/lwtrace/event.h @@ -1,9 +1,9 @@ #pragma once -#include "preprocessor.h" +#include "preprocessor.h" #include "signature.h" #include "param_traits.h" - + #include <library/cpp/lwtrace/protos/lwtrace.pb.h> namespace NLWTrace { diff --git a/library/cpp/lwtrace/kill_action.cpp b/library/cpp/lwtrace/kill_action.cpp index 2b74dc4587..ace41b7aec 100644 --- a/library/cpp/lwtrace/kill_action.cpp +++ b/library/cpp/lwtrace/kill_action.cpp @@ -1,11 +1,11 @@ -#include "kill_action.h" +#include "kill_action.h" #ifndef _win_ #include <sys/types.h> #include <signal.h> #endif -#include <stdlib.h> +#include <stdlib.h> using namespace NLWTrace; using namespace NLWTrace::NPrivate; diff --git a/library/cpp/lwtrace/log.h b/library/cpp/lwtrace/log.h index 56981a97f8..dad2197b0b 100644 --- a/library/cpp/lwtrace/log.h +++ b/library/cpp/lwtrace/log.h @@ -1,19 +1,19 @@ #pragma once -#include "probe.h" - -#include <util/datetime/base.h> -#include <util/generic/algorithm.h> -#include <util/generic/deque.h> +#include "probe.h" + +#include <util/datetime/base.h> +#include <util/generic/algorithm.h> +#include <util/generic/deque.h> #include <util/generic/noncopyable.h> #include <util/generic/vector.h> -#include <util/string/printf.h> -#include <util/system/atomic.h> -#include <util/system/hp_timer.h> +#include <util/string/printf.h> +#include <util/system/atomic.h> +#include <util/system/hp_timer.h> #include <util/system/mutex.h> #include <util/system/spinlock.h> #include <util/system/thread.h> -#include <util/system/tls.h> +#include <util/system/tls.h> namespace NLWTrace { // Cyclic buffer that pushes items to its back and pop item from front on overflow diff --git a/library/cpp/lwtrace/lwprobe.h b/library/cpp/lwtrace/lwprobe.h index 801fc3861b..0bd8253ea9 100644 --- a/library/cpp/lwtrace/lwprobe.h +++ b/library/cpp/lwtrace/lwprobe.h @@ -1,8 +1,8 @@ #pragma once -#include "control.h" -#include "probe.h" - +#include "control.h" +#include "probe.h" + #include <ctype.h> namespace NLWTrace { diff --git a/library/cpp/lwtrace/perf.cpp b/library/cpp/lwtrace/perf.cpp index 03b68586ea..190aca306f 100644 --- a/library/cpp/lwtrace/perf.cpp +++ b/library/cpp/lwtrace/perf.cpp @@ -1,7 +1,7 @@ #include "perf.h" -#include "probes.h" - +#include "probes.h" + #include <util/system/datetime.h> #include <util/system/hp_timer.h> diff --git a/library/cpp/lwtrace/preprocessor.h b/library/cpp/lwtrace/preprocessor.h index 40865467b2..396c7ff7f6 100644 --- a/library/cpp/lwtrace/preprocessor.h +++ b/library/cpp/lwtrace/preprocessor.h @@ -4,11 +4,11 @@ #include "perf.h" #include "symbol.h" -#include <util/generic/hide_ptr.h> -#include <util/system/platform.h> - -#include <stddef.h> //size_t - +#include <util/generic/hide_ptr.h> +#include <util/system/platform.h> + +#include <stddef.h> //size_t + #ifdef _win_ #ifndef LWTRACE_DISABLE #define LWTRACE_DISABLE diff --git a/library/cpp/lwtrace/probe.h b/library/cpp/lwtrace/probe.h index 31fa282da3..31cf4974c9 100644 --- a/library/cpp/lwtrace/probe.h +++ b/library/cpp/lwtrace/probe.h @@ -5,11 +5,11 @@ #include "rwspinlock.h" #include "shuttle.h" -#include <util/datetime/cputimer.h> -#include <util/generic/hide_ptr.h> +#include <util/datetime/cputimer.h> +#include <util/generic/hide_ptr.h> #include <util/generic/scope.h> -#include <util/system/atomic.h> - +#include <util/system/atomic.h> + namespace NLWTrace { // Represents a chain (linked list) of steps for execution of a trace query block // NOTE: different executor objects are used on different probes (even for the same query block) diff --git a/library/cpp/lwtrace/probes.h b/library/cpp/lwtrace/probes.h index 68810bd118..6513e941ab 100644 --- a/library/cpp/lwtrace/probes.h +++ b/library/cpp/lwtrace/probes.h @@ -1,6 +1,6 @@ #pragma once -#include "all.h" +#include "all.h" #define LWTRACE_INTERNAL_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ PROBE(PerfReport, GROUPS(), \ diff --git a/library/cpp/lwtrace/shuttle.h b/library/cpp/lwtrace/shuttle.h index 85c6e4da61..49f55efef2 100644 --- a/library/cpp/lwtrace/shuttle.h +++ b/library/cpp/lwtrace/shuttle.h @@ -1,15 +1,15 @@ #pragma once -#include "event.h" - +#include "event.h" + #include <library/cpp/containers/stack_vector/stack_vec.h> - + #include <util/generic/ptr.h> #include <util/system/spinlock.h> -#include <algorithm> +#include <algorithm> #include <type_traits> - + namespace NLWTrace { struct TProbe; diff --git a/library/cpp/lwtrace/signature.h b/library/cpp/lwtrace/signature.h index 868bd9bcf2..8ed5b8be4b 100644 --- a/library/cpp/lwtrace/signature.h +++ b/library/cpp/lwtrace/signature.h @@ -1,9 +1,9 @@ #pragma once -#include "preprocessor.h" - +#include "preprocessor.h" + #include <library/cpp/lwtrace/protos/lwtrace.pb.h> - + #include <util/generic/cast.h> #include <util/generic/string.h> #include <util/generic/typetraits.h> diff --git a/library/cpp/lwtrace/sleep_action.cpp b/library/cpp/lwtrace/sleep_action.cpp index 74977528db..ebcafa7d74 100644 --- a/library/cpp/lwtrace/sleep_action.cpp +++ b/library/cpp/lwtrace/sleep_action.cpp @@ -1,11 +1,11 @@ -#include "sleep_action.h" +#include "sleep_action.h" #include "control.h" - + #include <util/system/datetime.h> -#include <stdlib.h> - +#include <stdlib.h> + using namespace NLWTrace; using namespace NLWTrace::NPrivate; diff --git a/library/cpp/lwtrace/start.cpp b/library/cpp/lwtrace/start.cpp index 121d5472b6..ec971ce184 100644 --- a/library/cpp/lwtrace/start.cpp +++ b/library/cpp/lwtrace/start.cpp @@ -1,15 +1,15 @@ -#include "start.h" - -#include "all.h" +#include "start.h" +#include "all.h" + #include <google/protobuf/text_format.h> #include <util/generic/singleton.h> #include <util/stream/file.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/system/env.h> -#include <stdlib.h> +#include <stdlib.h> using namespace NLWTrace; diff --git a/library/cpp/lwtrace/stderr_writer.cpp b/library/cpp/lwtrace/stderr_writer.cpp index 6e5654c338..629b14135b 100644 --- a/library/cpp/lwtrace/stderr_writer.cpp +++ b/library/cpp/lwtrace/stderr_writer.cpp @@ -1,5 +1,5 @@ #include "stderr_writer.h" - + #include <util/stream/str.h> using namespace NLWTrace; diff --git a/library/cpp/lwtrace/symbol.cpp b/library/cpp/lwtrace/symbol.cpp index 456652bcd0..745437cb25 100644 --- a/library/cpp/lwtrace/symbol.cpp +++ b/library/cpp/lwtrace/symbol.cpp @@ -1,6 +1,6 @@ #include "symbol.h" - -#include <util/stream/output.h> + +#include <util/stream/output.h> #include <util/string/cast.h> template <> diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp index 3c974c85a0..2e756e2670 100644 --- a/library/cpp/lwtrace/trace.cpp +++ b/library/cpp/lwtrace/trace.cpp @@ -1,16 +1,16 @@ -#include "all.h" +#include "all.h" #include "kill_action.h" -#include "log_shuttle.h" -#include "preprocessor.h" +#include "log_shuttle.h" +#include "preprocessor.h" #include "sleep_action.h" -#include "stderr_writer.h" +#include "stderr_writer.h" #include "google/protobuf/repeated_field.h" - + #include <util/generic/map.h> #include <util/random/random.h> -#include <functional> - +#include <functional> + namespace NLWTrace { #ifndef LWTRACE_DISABLE diff --git a/library/cpp/threading/chunk_queue/queue.h b/library/cpp/threading/chunk_queue/queue.h index 55859601a1..311222e4dc 100644 --- a/library/cpp/threading/chunk_queue/queue.h +++ b/library/cpp/threading/chunk_queue/queue.h @@ -34,14 +34,14 @@ namespace NThreading { static_assert(sizeof(*this) % PadSize == 0, "padding does not work"); Y_UNUSED(Pad); } - - template<typename... Args> - TPadded(Args&&... args) - : T(std::forward<Args>(args)...) - { - static_assert(sizeof(*this) % PadSize == 0, "padding does not work"); - Y_UNUSED(Pad); - } + + template<typename... Args> + TPadded(Args&&... args) + : T(std::forward<Args>(args)...) + { + static_assert(sizeof(*this) % PadSize == 0, "padding does not work"); + Y_UNUSED(Pad); + } }; //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index 5fd4296a93..3973b9c170 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -16,10 +16,10 @@ namespace NThreading { //////////////////////////////////////////////////////////////////////////////// - enum class TError { - Error - }; - + enum class TError { + Error + }; + template <typename T> class TFutureState: public TAtomicRefCount<TFutureState<T>> { enum { @@ -89,13 +89,13 @@ namespace NThreading { { } - TFutureState(std::exception_ptr exception, TError) - : State(ExceptionSet) - , Exception(std::move(exception)) - , NullValue(0) - { - } - + TFutureState(std::exception_ptr exception, TError) + : State(ExceptionSet) + , Exception(std::move(exception)) + , NullValue(0) + { + } + ~TFutureState() { if (State >= ValueMoved) { // ValueMoved, ValueSet, ValueRead Value.~T(); @@ -277,12 +277,12 @@ namespace NThreading { { } - TFutureState(std::exception_ptr exception, TError) - : State(ExceptionSet) - , Exception(std::move(exception)) - { - } - + TFutureState(std::exception_ptr exception, TError) + : State(ExceptionSet) + , Exception(std::move(exception)) + { + } + bool HasValue() const { return AtomicGet(State) == ValueSet; } @@ -971,12 +971,12 @@ namespace NThreading { return Singleton<TCache>()->Instance; } - template <typename T> - inline TFuture<T> MakeErrorFuture(std::exception_ptr exception) - { - return {new NImpl::TFutureState<T>(std::move(exception), NImpl::TError::Error)}; - } - + template <typename T> + inline TFuture<T> MakeErrorFuture(std::exception_ptr exception) + { + return {new NImpl::TFutureState<T>(std::move(exception), NImpl::TError::Error)}; + } + inline TFuture<void> MakeFuture() { struct TCache { TFuture<void> Instance{new NImpl::TFutureState<void>(true)}; diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index 2e82bb953e..b8442f94c6 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -28,8 +28,8 @@ namespace NThreading { TFuture<std::remove_reference_t<T>> MakeFuture(T&& value); template <typename T> TFuture<T> MakeFuture(); - template <typename T> - TFuture<T> MakeErrorFuture(std::exception_ptr exception); + template <typename T> + TFuture<T> MakeErrorFuture(std::exception_ptr exception); TFuture<void> MakeFuture(); //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 05950a568d..f44272bef0 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -281,17 +281,17 @@ namespace { TVector<TFuture<void>> promises; promises.push_back(promise1); promises.push_back(promise2); - + TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(!future.HasValue()); - + promise1.SetValue(); UNIT_ASSERT(!future.HasValue()); - + promise2.SetValue(); UNIT_ASSERT(future.HasValue()); } - + Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) { TPromise<int> promise1 = NewPromise<int>(); TPromise<int> promise2 = NewPromise<int>(); @@ -313,7 +313,7 @@ namespace { Y_UNIT_TEST(ShouldWaitExceptionOrAllList) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); - + std::list<TFuture<void>> promises; promises.push_back(promise1); promises.push_back(promise2); @@ -334,25 +334,25 @@ namespace { TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(future.HasValue()); } - + Y_UNIT_TEST(ShouldWaitAnyVector) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); - + TVector<TFuture<void>> promises; promises.push_back(promise1); promises.push_back(promise2); - + TFuture<void> future = WaitAny(promises); UNIT_ASSERT(!future.HasValue()); - + promise1.SetValue(); UNIT_ASSERT(future.HasValue()); - + promise2.SetValue(); UNIT_ASSERT(future.HasValue()); } - + Y_UNIT_TEST(ShouldWaitAnyVectorWithValueType) { TPromise<int> promise1 = NewPromise<int>(); @@ -375,7 +375,7 @@ namespace { Y_UNIT_TEST(ShouldWaitAnyList) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); - + std::list<TFuture<void>> promises; promises.push_back(promise1); promises.push_back(promise2); @@ -396,11 +396,11 @@ namespace { TFuture<void> future = WaitAny(promises); UNIT_ASSERT(future.HasValue()); } - + Y_UNIT_TEST(ShouldWaitAny) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); - + TFuture<void> future = WaitAny(promise1, promise2); UNIT_ASSERT(!future.HasValue()); @@ -506,7 +506,7 @@ namespace { UNIT_ASSERT(promise.TrySetValue(42)); UNIT_ASSERT(!promise.TrySetValue(42)); } - + Y_UNIT_TEST(HandlingRepetitiveSetException) { TPromise<int> promise = NewPromise<int>(); promise.SetException("test"); @@ -519,24 +519,24 @@ namespace { UNIT_ASSERT(!promise.TrySetException(std::make_exception_ptr("test"))); } - Y_UNIT_TEST(ShouldAllowToMakeFutureWithException) - { - auto future1 = MakeErrorFuture<void>(std::make_exception_ptr(TFutureException())); - UNIT_ASSERT(future1.HasException()); - UNIT_CHECK_GENERATED_EXCEPTION(future1.GetValue(), TFutureException); - - auto future2 = MakeErrorFuture<int>(std::make_exception_ptr(TFutureException())); - UNIT_ASSERT(future2.HasException()); - UNIT_CHECK_GENERATED_EXCEPTION(future2.GetValue(), TFutureException); - - auto future3 = MakeFuture<std::exception_ptr>(std::make_exception_ptr(TFutureException())); - UNIT_ASSERT(future3.HasValue()); - UNIT_CHECK_GENERATED_NO_EXCEPTION(future3.GetValue(), TFutureException); - - auto future4 = MakeFuture<std::unique_ptr<int>>(nullptr); - UNIT_ASSERT(future4.HasValue()); - UNIT_CHECK_GENERATED_NO_EXCEPTION(future4.GetValue(), TFutureException); - } + Y_UNIT_TEST(ShouldAllowToMakeFutureWithException) + { + auto future1 = MakeErrorFuture<void>(std::make_exception_ptr(TFutureException())); + UNIT_ASSERT(future1.HasException()); + UNIT_CHECK_GENERATED_EXCEPTION(future1.GetValue(), TFutureException); + + auto future2 = MakeErrorFuture<int>(std::make_exception_ptr(TFutureException())); + UNIT_ASSERT(future2.HasException()); + UNIT_CHECK_GENERATED_EXCEPTION(future2.GetValue(), TFutureException); + + auto future3 = MakeFuture<std::exception_ptr>(std::make_exception_ptr(TFutureException())); + UNIT_ASSERT(future3.HasValue()); + UNIT_CHECK_GENERATED_NO_EXCEPTION(future3.GetValue(), TFutureException); + + auto future4 = MakeFuture<std::unique_ptr<int>>(nullptr); + UNIT_ASSERT(future4.HasValue()); + UNIT_CHECK_GENERATED_NO_EXCEPTION(future4.GetValue(), TFutureException); + } Y_UNIT_TEST(WaitAllowsExtract) { auto future = MakeFuture<int>(42); diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h index 2753d5446c..1803ab3dcc 100644 --- a/library/cpp/threading/future/wait/wait-inl.h +++ b/library/cpp/threading/future/wait/wait-inl.h @@ -28,7 +28,7 @@ namespace NThreading { [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); } - + template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) { return WaitAny(NImpl::ToVoidFutures(futures)); diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp index a173833a7f..c84d9864af 100644 --- a/library/cpp/threading/future/wait/wait.cpp +++ b/library/cpp/threading/future/wait/wait.cpp @@ -65,7 +65,7 @@ namespace NThreading { TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) { return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures); } - + //////////////////////////////////////////////////////////////////////////////// TFuture<void> WaitAny(const TFuture<void>& f1) { diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index 6ff7d57baa..493fe34298 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -29,8 +29,8 @@ namespace NThreading { [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); // waits for any future - [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1); - [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2); + [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1); + [[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2); [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures); template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures); |