diff options
author | Alexander Rutkovsky <alexvru@mail.ru> | 2022-02-10 16:47:40 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:40 +0300 |
commit | 667a4ee7da2e004784b9c3cfab824a81e96f4d66 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/monlib/dynamic_counters/contention_ut.cpp | |
parent | f3646f91e0de459836a7800b9ce3e8dc57a2ab3a (diff) | |
download | ydb-667a4ee7da2e004784b9c3cfab824a81e96f4d66.tar.gz |
Restoring authorship annotation for Alexander Rutkovsky <alexvru@mail.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/dynamic_counters/contention_ut.cpp')
-rw-r--r-- | library/cpp/monlib/dynamic_counters/contention_ut.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/monlib/dynamic_counters/contention_ut.cpp b/library/cpp/monlib/dynamic_counters/contention_ut.cpp index eac30069a6..8798044ee3 100644 --- a/library/cpp/monlib/dynamic_counters/contention_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/contention_ut.cpp @@ -1,61 +1,61 @@ -#include "counters.h" +#include "counters.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/system/event.h> -#include <util/system/thread.h> - -using namespace NMonitoring; - -Y_UNIT_TEST_SUITE(TDynamicCountersContentionTest) { - - Y_UNIT_TEST(EnsureNonlocking) { - TDynamicCounterPtr counters = MakeIntrusive<TDynamicCounters>(); - - class TConsumer : public ICountableConsumer { - TAutoEvent Ev; - TAutoEvent Response; - TDynamicCounterPtr Counters; - TThread Thread; - - public: - TConsumer(TDynamicCounterPtr counters) - : Counters(counters) - , Thread(std::bind(&TConsumer::ThreadFunc, this)) - { - Thread.Start(); - } - +#include <util/system/event.h> +#include <util/system/thread.h> + +using namespace NMonitoring; + +Y_UNIT_TEST_SUITE(TDynamicCountersContentionTest) { + + Y_UNIT_TEST(EnsureNonlocking) { + TDynamicCounterPtr counters = MakeIntrusive<TDynamicCounters>(); + + class TConsumer : public ICountableConsumer { + TAutoEvent Ev; + TAutoEvent Response; + TDynamicCounterPtr Counters; + TThread Thread; + + public: + TConsumer(TDynamicCounterPtr counters) + : Counters(counters) + , Thread(std::bind(&TConsumer::ThreadFunc, this)) + { + Thread.Start(); + } + ~TConsumer() override { - Thread.Join(); - } - + Thread.Join(); + } + void OnCounter(const TString& /*labelName*/, const TString& /*labelValue*/, const TCounterForPtr* /*counter*/) override { - Ev.Signal(); - Response.Wait(); - } - + Ev.Signal(); + Response.Wait(); + } + void OnHistogram(const TString& /*labelName*/, const TString& /*labelValue*/, IHistogramSnapshotPtr /*snapshot*/, bool /*derivative*/) override { - } - + } + void OnGroupBegin(const TString& /*labelName*/, const TString& /*labelValue*/, const TDynamicCounters* /*group*/) override { - } - + } + void OnGroupEnd(const TString& /*labelName*/, const TString& /*labelValue*/, const TDynamicCounters* /*group*/) override { - } - - private: - void ThreadFunc() { - // acts like a coroutine - Ev.Wait(); - auto ctr = Counters->GetSubgroup("label", "value")->GetCounter("name"); - Y_VERIFY(*ctr == 42); - Response.Signal(); - } - }; - - auto ctr = counters->GetSubgroup("label", "value")->GetCounter("name"); - *ctr = 42; - TConsumer consumer(counters); - counters->Accept({}, {}, consumer); - } - -} + } + + private: + void ThreadFunc() { + // acts like a coroutine + Ev.Wait(); + auto ctr = Counters->GetSubgroup("label", "value")->GetCounter("name"); + Y_VERIFY(*ctr == 42); + Response.Signal(); + } + }; + + auto ctr = counters->GetSubgroup("label", "value")->GetCounter("name"); + *ctr = 42; + TConsumer consumer(counters); + counters->Accept({}, {}, consumer); + } + +} |