diff options
author | vlad-kolotvin <vlad-kolotvin@yandex-team.ru> | 2022-02-10 16:48:20 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:20 +0300 |
commit | 9ff71a8b1ce582cb08730cb11eb25839441317d1 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | d26952c54d3ee92bbdc1888b64f3dec893e5a383 (diff) | |
download | ydb-9ff71a8b1ce582cb08730cb11eb25839441317d1.tar.gz |
Restoring authorship annotation for <vlad-kolotvin@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | contrib/tools/python3/src/Lib/multiprocessing/managers.py | 4 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/coroutine_ut.cpp | 84 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/custom_time.h | 20 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/impl.cpp | 76 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/impl.h | 32 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/trampoline.cpp | 26 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/trampoline.h | 14 | ||||
-rw-r--r-- | library/cpp/string_utils/url/url.cpp | 2 | ||||
-rw-r--r-- | library/cpp/string_utils/url/url_ut.cpp | 48 | ||||
-rw-r--r-- | util/generic/yexception.h | 4 | ||||
-rw-r--r-- | util/memory/blob.h | 10 |
11 files changed, 160 insertions, 160 deletions
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/managers.py b/contrib/tools/python3/src/Lib/multiprocessing/managers.py index 8271899037..dfa566c6fc 100644 --- a/contrib/tools/python3/src/Lib/multiprocessing/managers.py +++ b/contrib/tools/python3/src/Lib/multiprocessing/managers.py @@ -960,7 +960,7 @@ def MakeProxyType(name, exposed, _cache={}): def AutoProxy(token, serializer, manager=None, authkey=None, - exposed=None, incref=True, manager_owned=False): + exposed=None, incref=True, manager_owned=False): ''' Return an auto-proxy for `token` ''' @@ -980,7 +980,7 @@ def AutoProxy(token, serializer, manager=None, authkey=None, ProxyType = MakeProxyType('AutoProxy[%s]' % token.typeid, exposed) proxy = ProxyType(token, serializer, manager=manager, authkey=authkey, - incref=incref, manager_owned=manager_owned) + incref=incref, manager_owned=manager_owned) proxy._isauto = True return proxy diff --git a/library/cpp/coroutine/engine/coroutine_ut.cpp b/library/cpp/coroutine/engine/coroutine_ut.cpp index a240161405..8b372496a2 100644 --- a/library/cpp/coroutine/engine/coroutine_ut.cpp +++ b/library/cpp/coroutine/engine/coroutine_ut.cpp @@ -44,8 +44,8 @@ class TCoroTest: public TTestBase { UNIT_TEST(TestComputeCoroutineYield) UNIT_TEST(TestPollEngines); UNIT_TEST(TestUserEvent); - UNIT_TEST(TestPause); - UNIT_TEST(TestOverrideTime); + UNIT_TEST(TestPause); + UNIT_TEST(TestOverrideTime); UNIT_TEST_SUITE_END(); public: @@ -76,8 +76,8 @@ public: void TestComputeCoroutineYield(); void TestPollEngines(); void TestUserEvent(); - void TestPause(); - void TestOverrideTime(); + void TestPause(); + void TestOverrideTime(); }; void TCoroTest::TestException() { @@ -942,23 +942,23 @@ void TCoroTest::TestPollEngines() { UNIT_ASSERT(defaultChecked); } -void TCoroTest::TestPause() { +void TCoroTest::TestPause() { TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing()}; - - int i = 0; - executor.CreateOwned([&](TCont*) { - i++; - executor.Pause(); - i++; - }, "coro"); - - UNIT_ASSERT_EQUAL(i, 0); - executor.Execute(); - UNIT_ASSERT_EQUAL(i, 1); - executor.Execute(); - UNIT_ASSERT_EQUAL(i, 2); -} - + + int i = 0; + executor.CreateOwned([&](TCont*) { + i++; + executor.Pause(); + i++; + }, "coro"); + + UNIT_ASSERT_EQUAL(i, 0); + executor.Execute(); + UNIT_ASSERT_EQUAL(i, 1); + executor.Execute(); + UNIT_ASSERT_EQUAL(i, 2); +} + void TCoroTest::TestUserEvent() { TContExecutor exec(32000); @@ -981,27 +981,27 @@ void TCoroTest::TestUserEvent() { UNIT_ASSERT(event.Called); } - -void TCoroTest::TestOverrideTime() { - class TTime: public NCoro::ITime { - public: - TInstant Now() override { - return Current; - } - - TInstant Current = TInstant::Zero(); - }; - - TTime time; + +void TCoroTest::TestOverrideTime() { + class TTime: public NCoro::ITime { + public: + TInstant Now() override { + return Current; + } + + TInstant Current = TInstant::Zero(); + }; + + TTime time; TContExecutor executor{1024*1024, IPollerFace::Default(), nullptr, nullptr, NCoro::NStack::EGuard::Canary, Nothing(), &time}; - - executor.CreateOwned([&](TCont* cont) { - UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Zero()); - time.Current = TInstant::Seconds(1); - cont->SleepD(TInstant::Seconds(1)); - UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Seconds(1)); - }, "coro"); - - executor.Execute(); -} + + executor.CreateOwned([&](TCont* cont) { + UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Zero()); + time.Current = TInstant::Seconds(1); + cont->SleepD(TInstant::Seconds(1)); + UNIT_ASSERT_EQUAL(cont->Executor()->Now(), TInstant::Seconds(1)); + }, "coro"); + + executor.Execute(); +} UNIT_TEST_SUITE_REGISTRATION(TCoroTest); diff --git a/library/cpp/coroutine/engine/custom_time.h b/library/cpp/coroutine/engine/custom_time.h index ef8b0720b4..0bff0f6a60 100644 --- a/library/cpp/coroutine/engine/custom_time.h +++ b/library/cpp/coroutine/engine/custom_time.h @@ -1,10 +1,10 @@ -#pragma once - -#include <util/datetime/base.h> - -namespace NCoro { -class ITime { - public: - virtual TInstant Now() = 0; -}; -} +#pragma once + +#include <util/datetime/base.h> + +namespace NCoro { +class ITime { + public: + virtual TInstant Now() = 0; +}; +} diff --git a/library/cpp/coroutine/engine/impl.cpp b/library/cpp/coroutine/engine/impl.cpp index 2fab959fa9..7ae6f74051 100644 --- a/library/cpp/coroutine/engine/impl.cpp +++ b/library/cpp/coroutine/engine/impl.cpp @@ -21,15 +21,15 @@ void TCont::TJoinWait::Wake() noexcept { TCont::TCont(NCoro::NStack::IAllocator& allocator, uint32_t stackSize, TContExecutor& executor, - NCoro::TTrampoline::TFunc func, + NCoro::TTrampoline::TFunc func, const char* name) noexcept : Executor_(executor) , Name_(name) , Trampoline_( allocator, stackSize, - std::move(func), - this + std::move(func), + this ) {} @@ -122,14 +122,14 @@ TContExecutor::TContExecutor( NCoro::IScheduleCallback* scheduleCallback, NCoro::IEnterPollerCallback* enterPollerCallback, NCoro::NStack::EGuard defaultGuard, - TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings, - NCoro::ITime* time + TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings, + NCoro::ITime* time ) : ScheduleCallback_(scheduleCallback) , EnterPollerCallback_(enterPollerCallback) , DefaultStackSize_(defaultStackSize) , Poller_(std::move(poller)) - , Time_(time) + , Time_(time) { StackAllocator_ = NCoro::NStack::GetAllocator(poolSettings, defaultGuard); } @@ -144,15 +144,15 @@ void TContExecutor::Execute() noexcept { } void TContExecutor::Execute(TContFunc func, void* arg) noexcept { - CreateOwned([=](TCont* cont) { - func(cont, arg); - }, "sys_main"); + CreateOwned([=](TCont* cont) { + func(cont, arg); + }, "sys_main"); RunScheduler(); } void TContExecutor::WaitForIO() { while (Ready_.Empty() && !WaitQueue_.Empty()) { - const auto now = Now(); + const auto now = Now(); // Waking a coroutine puts it into ReadyNext_ list const auto next = WaitQueue_.WakeTimedout(now); @@ -234,21 +234,21 @@ TCont* TContExecutor::Create( const char* name, TMaybe<ui32> customStackSize ) noexcept { - return CreateOwned([=](TCont* cont) { - func(cont, arg); - }, name, customStackSize); -} - -TCont* TContExecutor::CreateOwned( - NCoro::TTrampoline::TFunc func, - const char* name, - TMaybe<ui32> customStackSize -) noexcept { + return CreateOwned([=](TCont* cont) { + func(cont, arg); + }, name, customStackSize); +} + +TCont* TContExecutor::CreateOwned( + NCoro::TTrampoline::TFunc func, + const char* name, + TMaybe<ui32> customStackSize +) noexcept { Allocated_ += 1; if (!customStackSize) { customStackSize = DefaultStackSize_; } - auto* cont = new TCont(*StackAllocator_, *customStackSize, *this, std::move(func), name); + auto* cont = new TCont(*StackAllocator_, *customStackSize, *this, std::move(func), name); ScheduleExecution(cont); return cont; } @@ -335,11 +335,11 @@ void TContExecutor::RunScheduler() noexcept { break; } context->SwitchTo(cont->Trampoline_.Context()); - if (Paused_) { - Paused_ = false; - Current_ = nullptr; - break; - } + if (Paused_) { + Paused_ = false; + Current_ = nullptr; + break; + } if (caller) { break; } @@ -350,24 +350,24 @@ void TContExecutor::RunScheduler() noexcept { } } -void TContExecutor::Pause() { - if (auto cont = Running()) { - Paused_ = true; - ScheduleExecutionNow(cont); - cont->SwitchTo(&SchedContext_); - } -} - +void TContExecutor::Pause() { + if (auto cont = Running()) { + Paused_ = true; + ScheduleExecutionNow(cont); + cont->SwitchTo(&SchedContext_); + } +} + void TContExecutor::Exit(TCont* cont) noexcept { ScheduleToDelete(cont); cont->SwitchTo(&SchedContext_); Y_FAIL("can not return from exit"); } -TInstant TContExecutor::Now() { - return Y_LIKELY(Time_ == nullptr) ? TInstant::Now() : Time_->Now(); -} - +TInstant TContExecutor::Now() { + return Y_LIKELY(Time_ == nullptr) ? TInstant::Now() : Time_->Now(); +} + template <> void Out<TCont>(IOutputStream& out, const TCont& c) { c.PrintMe(out); diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index dd2dee99ba..283a96ecf1 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -6,7 +6,7 @@ #include "poller.h" #include "stack/stack_common.h" #include "trampoline.h" -#include "custom_time.h" +#include "custom_time.h" #include <library/cpp/containers/intrusive_rb_tree/rb_tree.h> @@ -15,7 +15,7 @@ #include <util/generic/intrlist.h> #include <util/datetime/base.h> #include <util/generic/maybe.h> -#include <util/generic/function.h> +#include <util/generic/function.h> #define EWAKEDUP 34567 @@ -49,7 +49,7 @@ private: NCoro::NStack::IAllocator& allocator, uint32_t stackSize, TContExecutor& executor, - NCoro::TTrampoline::TFunc func, + NCoro::TTrampoline::TFunc func, const char* name ) noexcept; @@ -156,8 +156,8 @@ public: NCoro::IScheduleCallback* = nullptr, NCoro::IEnterPollerCallback* = nullptr, NCoro::NStack::EGuard stackGuard = NCoro::NStack::EGuard::Canary, - TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings = Nothing(), - NCoro::ITime* time = nullptr + TMaybe<NCoro::NStack::TPoolAllocatorSettings> poolSettings = Nothing(), + NCoro::ITime* time = nullptr ); ~TContExecutor(); @@ -202,12 +202,12 @@ public: TMaybe<ui32> customStackSize = Nothing() ) noexcept; - TCont* CreateOwned( - NCoro::TTrampoline::TFunc func, - const char* name, - TMaybe<ui32> customStackSize = Nothing() - ) noexcept; - + TCont* CreateOwned( + NCoro::TTrampoline::TFunc func, + const char* name, + TMaybe<ui32> customStackSize = Nothing() + ) noexcept; + NCoro::TContPoller* Poller() noexcept { return &Poller_; } @@ -265,9 +265,9 @@ public: void ScheduleUserEvent(IUserEvent* event) { UserEvents_.PushBack(event); } - - void Pause(); - TInstant Now(); + + void Pause(); + TInstant Now(); private: void Release(TCont* cont) noexcept; @@ -308,6 +308,6 @@ private: size_t Allocated_ = 0; TCont* Current_ = nullptr; bool FailOnError_ = false; - bool Paused_ = false; - NCoro::ITime* Time_ = nullptr; + bool Paused_ = false; + NCoro::ITime* Time_ = nullptr; }; diff --git a/library/cpp/coroutine/engine/trampoline.cpp b/library/cpp/coroutine/engine/trampoline.cpp index 2ec89fe23b..10ea69ddc3 100644 --- a/library/cpp/coroutine/engine/trampoline.cpp +++ b/library/cpp/coroutine/engine/trampoline.cpp @@ -14,21 +14,21 @@ namespace NCoro { -TTrampoline::TTrampoline(NStack::IAllocator& allocator, ui32 stackSize, TFunc f, TCont* cont) noexcept +TTrampoline::TTrampoline(NStack::IAllocator& allocator, ui32 stackSize, TFunc f, TCont* cont) noexcept : Stack_(allocator, stackSize, cont->Name()) , Clo_{this, Stack_.Get(), cont->Name()} , Ctx_(Clo_) - , Func_(std::move(f)) + , Func_(std::move(f)) , Cont_(cont) {} void TTrampoline::DoRun() { - if (Cont_->Executor()->FailOnError()) { - Func_(Cont_); - } else { - try { - Func_(Cont_); - } catch (...) {} + if (Cont_->Executor()->FailOnError()) { + Func_(Cont_); + } else { + try { + Func_(Cont_); + } catch (...) {} } Cont_->Terminate(); @@ -42,9 +42,9 @@ TTrampoline::TTrampoline(NStack::IAllocator& allocator, ui32 stackSize, TFunc f, return Cont_->Name(); } - void TTrampoline::DoRunNaked() { - DoRun(); - - abort(); - } + void TTrampoline::DoRunNaked() { + DoRun(); + + abort(); + } } diff --git a/library/cpp/coroutine/engine/trampoline.h b/library/cpp/coroutine/engine/trampoline.h index 6f17db5118..37b61cf015 100644 --- a/library/cpp/coroutine/engine/trampoline.h +++ b/library/cpp/coroutine/engine/trampoline.h @@ -23,13 +23,13 @@ namespace NCoro { class TTrampoline : public ITrampoLine, TNonCopyable { public: - typedef std::function<void (TCont*)> TFunc; - + typedef std::function<void (TCont*)> TFunc; + TTrampoline( NCoro::NStack::IAllocator& allocator, uint32_t stackSize, - TFunc f, - TCont* cont + TFunc f, + TCont* cont ) noexcept; TArrayRef<char> Stack() noexcept; @@ -46,15 +46,15 @@ namespace NCoro { void DoRun() override; - void DoRunNaked() override; - + void DoRunNaked() override; + private: const char* ContName() const noexcept; private: NStack::TStackHolder Stack_; const TContClosure Clo_; TExceptionSafeContext Ctx_; - TFunc Func_; + TFunc Func_; TCont* const Cont_; }; } diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 107dea6a45..85f4ac5d69 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -214,7 +214,7 @@ bool TryGetSchemeHostAndPort(const TStringBuf url, TStringBuf& scheme, TStringBu TStringBuf portStr; TStringBuf hostAndPort = GetHostAndPort(url.Tail(schemeSize)); - if (hostAndPort && hostAndPort.back() != ']' && hostAndPort.TryRSplit(':', host, portStr)) { + if (hostAndPort && hostAndPort.back() != ']' && hostAndPort.TryRSplit(':', host, portStr)) { // URL has port if (!TryFromString(portStr, port)) { return false; diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 4b4462c978..1588013893 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -216,30 +216,30 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL(host, "ya.ru"); UNIT_ASSERT_VALUES_EQUAL(port, 443); } - { // ipv6 - TStringBuf scheme("unknown"), host("unknown"); - ui16 port = 0; - GetSchemeHostAndPort("https://[1080:0:0:0:8:800:200C:417A]:443/bebe", scheme, host, port); - UNIT_ASSERT_VALUES_EQUAL(scheme, "https://"); - UNIT_ASSERT_VALUES_EQUAL(host, "[1080:0:0:0:8:800:200C:417A]"); - UNIT_ASSERT_VALUES_EQUAL(port, 443); - } - { // ipv6 - TStringBuf scheme("unknown"), host("unknown"); - ui16 port = 0; - GetSchemeHostAndPort("[::1]/bebe", scheme, host, port); - UNIT_ASSERT_VALUES_EQUAL(scheme, "unknown"); - UNIT_ASSERT_VALUES_EQUAL(host, "[::1]"); - UNIT_ASSERT_VALUES_EQUAL(port, 0); - } - { // ipv6 - TStringBuf scheme("unknown"), host("unknown"); - ui16 port = 0; - GetSchemeHostAndPort("unknown:///bebe", scheme, host, port); - UNIT_ASSERT_VALUES_EQUAL(scheme, "unknown://"); - UNIT_ASSERT_VALUES_EQUAL(host, ""); - UNIT_ASSERT_VALUES_EQUAL(port, 0); - } + { // ipv6 + TStringBuf scheme("unknown"), host("unknown"); + ui16 port = 0; + GetSchemeHostAndPort("https://[1080:0:0:0:8:800:200C:417A]:443/bebe", scheme, host, port); + UNIT_ASSERT_VALUES_EQUAL(scheme, "https://"); + UNIT_ASSERT_VALUES_EQUAL(host, "[1080:0:0:0:8:800:200C:417A]"); + UNIT_ASSERT_VALUES_EQUAL(port, 443); + } + { // ipv6 + TStringBuf scheme("unknown"), host("unknown"); + ui16 port = 0; + GetSchemeHostAndPort("[::1]/bebe", scheme, host, port); + UNIT_ASSERT_VALUES_EQUAL(scheme, "unknown"); + UNIT_ASSERT_VALUES_EQUAL(host, "[::1]"); + UNIT_ASSERT_VALUES_EQUAL(port, 0); + } + { // ipv6 + TStringBuf scheme("unknown"), host("unknown"); + ui16 port = 0; + GetSchemeHostAndPort("unknown:///bebe", scheme, host, port); + UNIT_ASSERT_VALUES_EQUAL(scheme, "unknown://"); + UNIT_ASSERT_VALUES_EQUAL(host, ""); + UNIT_ASSERT_VALUES_EQUAL(port, 0); + } // port overflow auto testCase = []() { TStringBuf scheme("unknown"), host("unknown"); diff --git a/util/generic/yexception.h b/util/generic/yexception.h index 9fa2d095d2..b0c604e8c4 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -173,8 +173,8 @@ bool UncaughtException() noexcept; std::string CurrentExceptionTypeName(); -TString FormatExc(const std::exception& exception); - +TString FormatExc(const std::exception& exception); + #define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \ do { \ if (Y_UNLIKELY(!(CONDITION))) { \ diff --git a/util/memory/blob.h b/util/memory/blob.h index e5066859e2..20c02a68df 100644 --- a/util/memory/blob.h +++ b/util/memory/blob.h @@ -116,11 +116,11 @@ public: return !Length(); } - /// Checks if the blob owns data - Y_PURE_FUNCTION inline bool OwnsData() const noexcept { - return S_.Base != nullptr; - } - + /// Checks if the blob owns data + Y_PURE_FUNCTION inline bool OwnsData() const noexcept { + return S_.Base != nullptr; + } + /// Checks if the object has a data array. inline bool IsNull() const noexcept { return !Data(); |