aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrofimenkov <trofimenkov@yandex-team.ru>2022-02-10 16:49:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:30 +0300
commit30cebc2cfa79af3b577760a113e203a79450e6b6 (patch)
tree49327bf3c28fab534b04b312a39179e70f7c2763
parenta2d2743094c8d255cda4011b317235874db4d01c (diff)
downloadydb-30cebc2cfa79af3b577760a113e203a79450e6b6.tar.gz
Restoring authorship annotation for <trofimenkov@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/grpc/server/ut/stream_adaptor_ut.cpp2
-rw-r--r--library/cpp/http/io/headers.h6
-rw-r--r--library/cpp/http/io/headers_ut.cpp256
-rw-r--r--library/cpp/http/misc/httpreqdata.cpp8
-rw-r--r--library/cpp/http/misc/httpreqdata.h10
-rw-r--r--library/cpp/http/misc/httpreqdata_ut.cpp62
-rw-r--r--library/cpp/http/server/http.cpp38
-rw-r--r--library/cpp/http/server/options.h24
-rw-r--r--library/cpp/json/writer/json_value.cpp28
-rw-r--r--library/cpp/json/writer/json_value.h2
-rw-r--r--library/cpp/logger/element.cpp10
-rw-r--r--library/cpp/logger/element_ut.cpp64
-rw-r--r--library/cpp/logger/thread.cpp2
-rw-r--r--library/cpp/logger/ut/ya.make2
-rw-r--r--library/cpp/threading/task_scheduler/task_scheduler.cpp4
-rw-r--r--library/cpp/tvmauth/client/misc/threaded_updater.cpp4
-rw-r--r--library/python/ya.make4
-rw-r--r--util/generic/hash.h16
-rw-r--r--util/generic/maybe.h36
-rw-r--r--util/memory/tempbuf.cpp12
-rw-r--r--util/memory/tempbuf_ut.cpp30
-rw-r--r--util/system/mutex.cpp2
-rw-r--r--util/thread/pool.cpp172
-rw-r--r--util/thread/pool.h142
-rw-r--r--util/thread/pool_ut.cpp176
-rw-r--r--util/ysaveload_ut.cpp94
-rw-r--r--ydb/library/backup/query_uploader.cpp2
-rw-r--r--ydb/library/yql/core/user_data/yql_user_data.cpp2
-rw-r--r--ydb/public/sdk/cpp/client/ydb_table/impl/request_migrator_ut.cpp2
29 files changed, 606 insertions, 606 deletions
diff --git a/library/cpp/grpc/server/ut/stream_adaptor_ut.cpp b/library/cpp/grpc/server/ut/stream_adaptor_ut.cpp
index c34d3b8c2b..52c0417571 100644
--- a/library/cpp/grpc/server/ut/stream_adaptor_ut.cpp
+++ b/library/cpp/grpc/server/ut/stream_adaptor_ut.cpp
@@ -51,7 +51,7 @@ Y_UNIT_TEST_SUITE(StreamAdaptor) {
const i64 max = 10000;
// Here we will emulate grpc stream (NextReply call after writing)
- std::unique_ptr<IThreadPool> consumerQueue(new TThreadPool(TThreadPool::TParams().SetBlocking(false).SetCatching(false)));
+ std::unique_ptr<IThreadPool> consumerQueue(new TThreadPool(TThreadPool::TParams().SetBlocking(false).SetCatching(false)));
// And make sure only one request inflight (see UNIT_ASSERT on adding to the queue)
consumerQueue->Start(threads, 1);
diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h
index a71793d1c6..5df294fa71 100644
--- a/library/cpp/http/io/headers.h
+++ b/library/cpp/http/io/headers.h
@@ -84,11 +84,11 @@ public:
/// Добавляет заголовок в контейнер.
void AddHeader(THttpInputHeader header);
- template <typename ValueType>
+ template <typename ValueType>
void AddHeader(TString name, const ValueType& value) {
AddHeader(THttpInputHeader(std::move(name), ToString(value)));
- }
-
+ }
+
/// Добавляет заголовок в контейнер, если тот не содержит заголовка
/// c таким же параметром. В противном случае, заменяет существующий
/// заголовок на новый.
diff --git a/library/cpp/http/io/headers_ut.cpp b/library/cpp/http/io/headers_ut.cpp
index 1d23ef8fdc..2f6c19b812 100644
--- a/library/cpp/http/io/headers_ut.cpp
+++ b/library/cpp/http/io/headers_ut.cpp
@@ -1,78 +1,78 @@
-#include <util/generic/set.h>
+#include <util/generic/set.h>
#include <util/generic/string.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <utility>
-
+
#include <library/cpp/http/io/headers.h>
#include <library/cpp/testing/unittest/registar.h>
-
-namespace {
- class THeadersExistence {
- public:
+
+namespace {
+ class THeadersExistence {
+ public:
THeadersExistence() = default;
-
- THeadersExistence(const THttpHeaders& headers) {
- for (THttpHeaders::TConstIterator it = headers.Begin();
+
+ THeadersExistence(const THttpHeaders& headers) {
+ for (THttpHeaders::TConstIterator it = headers.Begin();
it != headers.End();
++it) {
- Add(it->Name(), it->Value());
- }
- }
-
- public:
+ Add(it->Name(), it->Value());
+ }
+ }
+
+ public:
void Add(TStringBuf name, TStringBuf value) {
Impl.emplace(TString(name), TString(value));
- }
-
+ }
+
bool operator==(const THeadersExistence& rhs) const {
- return Impl == rhs.Impl;
- }
-
- private:
+ return Impl == rhs.Impl;
+ }
+
+ private:
typedef TMultiSet<std::pair<TString, TString>> TImpl;
- TImpl Impl;
- };
-}
-
+ TImpl Impl;
+ };
+}
+
bool operator==(const THeadersExistence& lhs, const THttpHeaders& rhs) {
- return lhs == THeadersExistence(rhs);
-}
-
+ return lhs == THeadersExistence(rhs);
+}
+
bool operator==(const THttpHeaders& lhs, const THeadersExistence& rhs) {
- return THeadersExistence(lhs) == rhs;
-}
-
-class THttpHeadersTest: public TTestBase {
- UNIT_TEST_SUITE(THttpHeadersTest);
- UNIT_TEST(TestAddOperation1Arg);
- UNIT_TEST(TestAddOperation2Args);
- UNIT_TEST(TestAddOrReplaceOperation1Arg);
- UNIT_TEST(TestAddOrReplaceOperation2Args);
- UNIT_TEST(TestAddHeaderTemplateness);
+ return THeadersExistence(lhs) == rhs;
+}
+
+class THttpHeadersTest: public TTestBase {
+ UNIT_TEST_SUITE(THttpHeadersTest);
+ UNIT_TEST(TestAddOperation1Arg);
+ UNIT_TEST(TestAddOperation2Args);
+ UNIT_TEST(TestAddOrReplaceOperation1Arg);
+ UNIT_TEST(TestAddOrReplaceOperation2Args);
+ UNIT_TEST(TestAddHeaderTemplateness);
UNIT_TEST(TestFindHeader);
- UNIT_TEST_SUITE_END();
-
-private:
+ UNIT_TEST_SUITE_END();
+
+private:
typedef void (*TAddHeaderFunction)(THttpHeaders&, TStringBuf name, TStringBuf value);
typedef void (*TAddOrReplaceHeaderFunction)(THttpHeaders&, TStringBuf name, TStringBuf value);
-
-public:
- void TestAddOperation1Arg();
- void TestAddOperation2Args();
- void TestAddOrReplaceOperation1Arg();
- void TestAddOrReplaceOperation2Args();
- void TestAddHeaderTemplateness();
+
+public:
+ void TestAddOperation1Arg();
+ void TestAddOperation2Args();
+ void TestAddOrReplaceOperation1Arg();
+ void TestAddOrReplaceOperation2Args();
+ void TestAddHeaderTemplateness();
void TestFindHeader();
-
-private:
+
+private:
static void AddHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
headers.AddHeader(THttpInputHeader(TString(name), TString(value)));
- }
-
+ }
+
static void AddHeaderImpl2Args(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
headers.AddHeader(TString(name), TString(value));
- }
-
+ }
+
static void AddOrReplaceHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
headers.AddOrReplaceHeader(THttpInputHeader(TString(name), TString(value)));
}
@@ -81,91 +81,91 @@ private:
headers.AddOrReplaceHeader(TString(name), TString(value));
}
- void DoTestAddOperation(TAddHeaderFunction);
+ void DoTestAddOperation(TAddHeaderFunction);
void DoTestAddOrReplaceOperation(TAddHeaderFunction, TAddOrReplaceHeaderFunction);
-};
-
-UNIT_TEST_SUITE_REGISTRATION(THttpHeadersTest);
-
-void THttpHeadersTest::TestAddOperation1Arg() {
- DoTestAddOperation(AddHeaderImpl1Arg);
-}
-void THttpHeadersTest::TestAddOperation2Args() {
- DoTestAddOperation(AddHeaderImpl2Args);
-}
-
-void THttpHeadersTest::TestAddOrReplaceOperation1Arg() {
+};
+
+UNIT_TEST_SUITE_REGISTRATION(THttpHeadersTest);
+
+void THttpHeadersTest::TestAddOperation1Arg() {
+ DoTestAddOperation(AddHeaderImpl1Arg);
+}
+void THttpHeadersTest::TestAddOperation2Args() {
+ DoTestAddOperation(AddHeaderImpl2Args);
+}
+
+void THttpHeadersTest::TestAddOrReplaceOperation1Arg() {
DoTestAddOrReplaceOperation(AddHeaderImpl1Arg, AddOrReplaceHeaderImpl1Arg);
-}
-void THttpHeadersTest::TestAddOrReplaceOperation2Args() {
+}
+void THttpHeadersTest::TestAddOrReplaceOperation2Args() {
DoTestAddOrReplaceOperation(AddHeaderImpl2Args, AddOrReplaceHeaderImpl2Args);
-}
-
-void THttpHeadersTest::DoTestAddOperation(TAddHeaderFunction addHeader) {
- THttpHeaders h1;
-
- addHeader(h1, "h1", "v1");
- addHeader(h1, "h2", "v1");
-
- addHeader(h1, "h3", "v1");
- addHeader(h1, "h3", "v2");
- addHeader(h1, "h3", "v2");
-
- THeadersExistence h2;
-
- h2.Add("h1", "v1");
- h2.Add("h2", "v1");
-
- h2.Add("h3", "v1");
- h2.Add("h3", "v2");
- h2.Add("h3", "v2");
-
- UNIT_ASSERT(h2 == h1);
-}
-
-// Sorry, but AddOrReplaceHeader replaces only first occurence
+}
+
+void THttpHeadersTest::DoTestAddOperation(TAddHeaderFunction addHeader) {
+ THttpHeaders h1;
+
+ addHeader(h1, "h1", "v1");
+ addHeader(h1, "h2", "v1");
+
+ addHeader(h1, "h3", "v1");
+ addHeader(h1, "h3", "v2");
+ addHeader(h1, "h3", "v2");
+
+ THeadersExistence h2;
+
+ h2.Add("h1", "v1");
+ h2.Add("h2", "v1");
+
+ h2.Add("h3", "v1");
+ h2.Add("h3", "v2");
+ h2.Add("h3", "v2");
+
+ UNIT_ASSERT(h2 == h1);
+}
+
+// Sorry, but AddOrReplaceHeader replaces only first occurence
void THttpHeadersTest::DoTestAddOrReplaceOperation(TAddHeaderFunction addHeader, TAddOrReplaceHeaderFunction addOrReplaceHeader) {
- THttpHeaders h1;
-
- addHeader(h1, "h1", "v1");
-
+ THttpHeaders h1;
+
+ addHeader(h1, "h1", "v1");
+
addOrReplaceHeader(h1, "h2", "v1");
addOrReplaceHeader(h1, "h2", "v2");
addOrReplaceHeader(h1, "h2", "v3");
- addHeader(h1, "h2", "v4");
-
- addHeader(h1, "h3", "v1");
- addHeader(h1, "h3", "v2");
+ addHeader(h1, "h2", "v4");
+
+ addHeader(h1, "h3", "v1");
+ addHeader(h1, "h3", "v2");
addOrReplaceHeader(h1, "h3", "v3");
-
- THeadersExistence h2;
-
- h2.Add("h1", "v1");
-
- h2.Add("h2", "v3");
- h2.Add("h2", "v4");
-
- h2.Add("h3", "v2");
- h2.Add("h3", "v3");
-
- UNIT_ASSERT(h2 == h1);
-}
-
-void THttpHeadersTest::TestAddHeaderTemplateness() {
- THttpHeaders h1;
- h1.AddHeader("h1", "v1");
+
+ THeadersExistence h2;
+
+ h2.Add("h1", "v1");
+
+ h2.Add("h2", "v3");
+ h2.Add("h2", "v4");
+
+ h2.Add("h3", "v2");
+ h2.Add("h3", "v3");
+
+ UNIT_ASSERT(h2 == h1);
+}
+
+void THttpHeadersTest::TestAddHeaderTemplateness() {
+ THttpHeaders h1;
+ h1.AddHeader("h1", "v1");
h1.AddHeader("h2", TString("v2"));
h1.AddHeader("h3", TStringBuf("v3"));
h1.AddHeader("h4", TStringBuf("v4"));
-
- THeadersExistence h2;
- h2.Add("h1", "v1");
- h2.Add("h2", "v2");
- h2.Add("h3", "v3");
- h2.Add("h4", "v4");
-
- UNIT_ASSERT(h1 == h2);
-}
+
+ THeadersExistence h2;
+ h2.Add("h1", "v1");
+ h2.Add("h2", "v2");
+ h2.Add("h3", "v3");
+ h2.Add("h4", "v4");
+
+ UNIT_ASSERT(h1 == h2);
+}
void THttpHeadersTest::TestFindHeader() {
THttpHeaders sut;
diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp
index f6951f68cd..4384caf0cf 100644
--- a/library/cpp/http/misc/httpreqdata.cpp
+++ b/library/cpp/http/misc/httpreqdata.cpp
@@ -21,7 +21,7 @@ TBaseServerRequestData::TBaseServerRequestData(const char* qs, SOCKET s)
, Path(nullptr)
, Search((char*)qs)
, SearchLength(qs ? strlen(qs) : 0)
- , OrigSearch(Search, SearchLength)
+ , OrigSearch(Search, SearchLength)
, Socket(s)
, BeginTime(MicroSeconds())
{
@@ -110,7 +110,7 @@ const char* TBaseServerRequestData::Environment(const char* key) const {
void TBaseServerRequestData::Clear() {
HeadersIn_.clear();
Addr = Path = Search = nullptr;
- OrigSearch = {};
+ OrigSearch = {};
SearchLength = 0;
Host.clear();
Port.clear();
@@ -174,8 +174,8 @@ bool TBaseServerRequestData::Parse(const char* origReq) {
} else {
SearchLength = 0;
}
- OrigSearch = {Search, SearchLength};
-
+ OrigSearch = {Search, SearchLength};
+
return true;
}
diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h
index 16e59c4d78..09389fa4af 100644
--- a/library/cpp/http/misc/httpreqdata.h
+++ b/library/cpp/http/misc/httpreqdata.h
@@ -51,10 +51,10 @@ public:
return TStringBuf(Search, SearchLength);
}
- TStringBuf OrigQueryStringBuf() const {
- return OrigSearch;
- }
-
+ TStringBuf OrigQueryStringBuf() const {
+ return OrigSearch;
+ }
+
void AppendQueryString(const char* str, size_t length);
const char* RemoteAddr() const;
void SetRemoteAddr(TStringBuf addr);
@@ -94,7 +94,7 @@ private:
char* Path;
char* Search;
size_t SearchLength; // length of Search
- TStringBuf OrigSearch;
+ TStringBuf OrigSearch;
THttpHeadersContainer HeadersIn_;
mutable char AddrData[INET6_ADDRSTRLEN];
SOCKET Socket;
diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp
index e7f16ef27c..a0ae26ea84 100644
--- a/library/cpp/http/misc/httpreqdata_ut.cpp
+++ b/library/cpp/http/misc/httpreqdata_ut.cpp
@@ -51,9 +51,9 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) {
// This should work
UNIT_ASSERT(rd.Parse(" /yandsearch?&gta=fake&haha=da HTTP 1.1 OK"));
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "&gta=fake&haha=da");
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf());
-
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "&gta=fake&haha=da");
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf());
+
rd.Scan();
UNIT_ASSERT(rd.CgiParam.Has("gta", "fake"));
UNIT_ASSERT(rd.CgiParam.Has("haha", "da"));
@@ -63,27 +63,27 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) {
}
Y_UNIT_TEST(Ctor) {
- const TString qs("gta=fake&haha=da");
- TServerRequestData rd(qs.c_str());
-
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
- UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
-
+ const TString qs("gta=fake&haha=da");
+ TServerRequestData rd(qs.c_str());
+
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
+ UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
+
UNIT_ASSERT(rd.CgiParam.Has("gta"));
UNIT_ASSERT(rd.CgiParam.Has("haha"));
UNIT_ASSERT(!rd.CgiParam.Has("no-param"));
}
Y_UNIT_TEST(HashCut) {
- const TString qs("&gta=fake&haha=da");
- const TString header = " /yandsearch?" + qs + "#&uberParam=yes&q=? HTTP 1.1 OK";
-
+ const TString qs("&gta=fake&haha=da");
+ const TString header = " /yandsearch?" + qs + "#&uberParam=yes&q=? HTTP 1.1 OK";
+
TServerRequestData rd;
- rd.Parse(header.c_str());
-
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
- UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
+ rd.Parse(header.c_str());
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
+ UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
+
rd.Scan();
UNIT_ASSERT(rd.CgiParam.Has("gta"));
UNIT_ASSERT(rd.CgiParam.Has("haha"));
@@ -94,9 +94,9 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) {
TServerRequestData rd;
rd.Parse(" /y#ndsearch?&gta=fake&haha=da&uberParam=yes&q=? HTTP 1.1 OK");
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "");
- UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), "");
-
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "");
+ UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), "");
+
rd.Scan();
UNIT_ASSERT(rd.CgiParam.empty());
}
@@ -105,29 +105,29 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) {
TServerRequestData rd;
rd.Parse(" /yandsearch?#");
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "");
- UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), "");
-
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), "");
+ UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), "");
+
rd.Scan();
UNIT_ASSERT(rd.CgiParam.empty());
}
Y_UNIT_TEST(AppendQueryString) {
- const TString qs("gta=fake&haha=da");
- TServerRequestData rd(qs.c_str());
+ const TString qs("gta=fake&haha=da");
+ TServerRequestData rd(qs.c_str());
UNIT_ASSERT(rd.CgiParam.Has("gta", "fake"));
UNIT_ASSERT(rd.CgiParam.Has("haha", "da"));
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf());
-
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs);
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf());
+
constexpr TStringBuf appendix = "gta=true&gta=new";
rd.AppendQueryString(appendix.data(), appendix.size());
-
- UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs + '&' + appendix);
- UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
-
+
+ UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs + '&' + appendix);
+ UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs);
+
rd.Scan();
UNIT_ASSERT(rd.CgiParam.Has("gta", "true"));
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index 128583bdd7..6683052c8e 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -321,8 +321,8 @@ public:
};
void ListenSocket() {
- TThread::SetCurrentThreadName(Options_.ListenThreadName.c_str());
-
+ TThread::SetCurrentThreadName(Options_.ListenThreadName.c_str());
+
ErrorCode = 0;
TIntrusiveListWithAutoDelete<TListenSocket, TDelete> Reqs;
@@ -410,8 +410,8 @@ public:
: TImpl(
parent,
cb,
- MakeThreadPool<TSimpleThreadPool>(factory, options.UseElasticQueues, cb, options.RequestsThreadName),
- MakeThreadPool<TThreadPool>(factory, options.UseElasticQueues, nullptr, options.FailRequestsThreadName),
+ MakeThreadPool<TSimpleThreadPool>(factory, options.UseElasticQueues, cb, options.RequestsThreadName),
+ MakeThreadPool<TThreadPool>(factory, options.UseElasticQueues, nullptr, options.FailRequestsThreadName),
options) {
}
@@ -461,17 +461,17 @@ public:
private:
template <class TThreadPool_>
- static THolder<IThreadPool> MakeThreadPool(IThreadFactory* factory, bool elastic, ICallBack* callback = nullptr, const TString& threadName = {}) {
+ static THolder<IThreadPool> MakeThreadPool(IThreadFactory* factory, bool elastic, ICallBack* callback = nullptr, const TString& threadName = {}) {
if (!factory) {
factory = SystemThreadFactory();
}
THolder<IThreadPool> pool;
- const auto params = IThreadPool::TParams().SetFactory(factory).SetThreadName(threadName);
+ const auto params = IThreadPool::TParams().SetFactory(factory).SetThreadName(threadName);
if (callback) {
- pool = MakeHolder<TThreadPoolBinder<TThreadPool_, THttpServer::ICallBack>>(callback, params);
+ pool = MakeHolder<TThreadPoolBinder<TThreadPool_, THttpServer::ICallBack>>(callback, params);
} else {
- pool = MakeHolder<TThreadPool_>(params);
+ pool = MakeHolder<TThreadPool_>(params);
}
if (elastic) {
@@ -631,20 +631,20 @@ bool TClientRequest::Reply(void* /*ThreadSpecificResource*/) {
bool TClientRequest::IsLocal() const {
return HasLocalAddress(Socket());
-}
-
-bool TClientRequest::CheckLoopback() {
- bool isLocal = false;
-
- try {
- isLocal = IsLocal();
- } catch (const yexception& e) {
+}
+
+bool TClientRequest::CheckLoopback() {
+ bool isLocal = false;
+
+ try {
+ isLocal = IsLocal();
+ } catch (const yexception& e) {
Output() << "HTTP/1.0 500 Oops\r\n\r\n"
<< e.what() << "\r\n";
return false;
- }
-
- if (!isLocal) {
+ }
+
+ if (!isLocal) {
Output() << "HTTP/1.0 403 Permission denied\r\n"
"Content-Type: text/html; charset=windows-1251\r\n"
"Connection: close\r\n"
diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h
index 38eda0e5e7..8510261b72 100644
--- a/library/cpp/http/server/options.h
+++ b/library/cpp/http/server/options.h
@@ -131,14 +131,14 @@ public:
return *this;
}
- inline THttpServerOptions& SetThreadsName(const TString& listenThreadName, const TString& requestsThreadName, const TString& failRequestsThreadName) noexcept {
- ListenThreadName = listenThreadName;
- RequestsThreadName = requestsThreadName;
- FailRequestsThreadName = failRequestsThreadName;
-
- return *this;
- }
-
+ inline THttpServerOptions& SetThreadsName(const TString& listenThreadName, const TString& requestsThreadName, const TString& failRequestsThreadName) noexcept {
+ ListenThreadName = listenThreadName;
+ RequestsThreadName = requestsThreadName;
+ FailRequestsThreadName = failRequestsThreadName;
+
+ return *this;
+ }
+
struct TAddr {
TString Addr;
ui16 Port;
@@ -169,8 +169,8 @@ public:
TDuration PollTimeout; // timeout of TSocketPoller::WaitT call
TDuration ExpirationTimeout; // drop inactive connections after ExpirationTimeout (should be > 0)
-
- TString ListenThreadName = "HttpListen";
- TString RequestsThreadName = "HttpServer";
- TString FailRequestsThreadName = "HttpServer";
+
+ TString ListenThreadName = "HttpListen";
+ TString RequestsThreadName = "HttpServer";
+ TString FailRequestsThreadName = "HttpServer";
};
diff --git a/library/cpp/json/writer/json_value.cpp b/library/cpp/json/writer/json_value.cpp
index c61e8d1dc4..59dda03fe7 100644
--- a/library/cpp/json/writer/json_value.cpp
+++ b/library/cpp/json/writer/json_value.cpp
@@ -427,38 +427,38 @@ namespace NJson {
bool TJsonValue::GetBooleanSafe() const {
if (Type != JSON_BOOLEAN)
ythrow TJsonException() << "Not a boolean";
-
+
return Value.Boolean;
}
-
+
long long TJsonValue::GetIntegerSafe() const {
if (!IsInteger())
ythrow TJsonException() << "Not an integer";
-
+
return GetInteger();
}
-
+
unsigned long long TJsonValue::GetUIntegerSafe() const {
if (!IsUInteger())
ythrow TJsonException() << "Not an unsigned integer";
-
+
return GetUInteger();
}
-
+
double TJsonValue::GetDoubleSafe() const {
if (!IsDouble())
ythrow TJsonException() << "Not a double";
-
+
return GetDouble();
}
-
+
const TString& TJsonValue::GetStringSafe() const {
if (Type != JSON_STRING)
ythrow TJsonException() << "Not a string";
-
+
return Value.String;
}
-
+
bool TJsonValue::GetBooleanSafe(const bool defaultValue) const {
if (Type == JSON_UNDEFINED)
return defaultValue;
@@ -497,10 +497,10 @@ namespace NJson {
const TJsonValue::TMapType& TJsonValue::GetMapSafe() const {
if (Type != JSON_MAP)
ythrow TJsonException() << "Not a map";
-
+
return *Value.Map;
}
-
+
TJsonValue::TMapType& TJsonValue::GetMapSafe() {
return const_cast<TJsonValue::TMapType&>(const_cast<const TJsonValue*>(this)->GetMapSafe());
}
@@ -508,10 +508,10 @@ namespace NJson {
const TJsonValue::TArray& TJsonValue::GetArraySafe() const {
if (Type != JSON_ARRAY)
ythrow TJsonException() << "Not an array";
-
+
return *Value.Array;
}
-
+
TJsonValue::TArray& TJsonValue::GetArraySafe() {
return const_cast<TJsonValue::TArray&>(const_cast<const TJsonValue*>(this)->GetArraySafe());
}
diff --git a/library/cpp/json/writer/json_value.h b/library/cpp/json/writer/json_value.h
index 3f0f50bc4c..b634613f26 100644
--- a/library/cpp/json/writer/json_value.h
+++ b/library/cpp/json/writer/json_value.h
@@ -129,7 +129,7 @@ namespace NJson {
unsigned long long GetUIntegerSafe(unsigned long long defaultValue) const;
double GetDoubleSafe(double defaultValue) const;
TString GetStringSafe(const TString& defaultValue) const;
-
+
bool GetBooleanRobust() const noexcept;
long long GetIntegerRobust() const noexcept;
unsigned long long GetUIntegerRobust() const noexcept;
diff --git a/library/cpp/logger/element.cpp b/library/cpp/logger/element.cpp
index b510fe16e1..e39b4607bf 100644
--- a/library/cpp/logger/element.cpp
+++ b/library/cpp/logger/element.cpp
@@ -2,7 +2,7 @@
#include "element.h"
#include <utility>
-
+
TLogElement::TLogElement(const TLog* parent)
: Parent_(parent)
, Priority_(Parent_->DefaultPriority())
@@ -25,10 +25,10 @@ TLogElement::~TLogElement() {
}
void TLogElement::DoFlush() {
- if (IsNull()) {
- return;
- }
-
+ if (IsNull()) {
+ return;
+ }
+
const size_t filled = Filled();
if (filled) {
diff --git a/library/cpp/logger/element_ut.cpp b/library/cpp/logger/element_ut.cpp
index 32edc52dfb..fa7fa835bf 100644
--- a/library/cpp/logger/element_ut.cpp
+++ b/library/cpp/logger/element_ut.cpp
@@ -1,39 +1,39 @@
-#include "log.h"
-#include "element.h"
-#include "stream.h"
-
+#include "log.h"
+#include "element.h"
+#include "stream.h"
+
#include <util/generic/string.h>
-#include <util/stream/str.h>
-#include <util/generic/ptr.h>
+#include <util/stream/str.h>
+#include <util/generic/ptr.h>
#include <utility>
-
+
#include <library/cpp/testing/unittest/registar.h>
-
-class TLogElementTest: public TTestBase {
- UNIT_TEST_SUITE(TLogElementTest);
- UNIT_TEST(TestMoveCtor);
- UNIT_TEST_SUITE_END();
-
-public:
- void TestMoveCtor();
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TLogElementTest);
-
-void TLogElementTest::TestMoveCtor() {
- TStringStream output;
+
+class TLogElementTest: public TTestBase {
+ UNIT_TEST_SUITE(TLogElementTest);
+ UNIT_TEST(TestMoveCtor);
+ UNIT_TEST_SUITE_END();
+
+public:
+ void TestMoveCtor();
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TLogElementTest);
+
+void TLogElementTest::TestMoveCtor() {
+ TStringStream output;
TLog log(MakeHolder<TStreamLogBackend>(&output));
-
+
THolder<TLogElement> src = MakeHolder<TLogElement>(&log);
-
+
TString message = "Hello, World!";
- (*src) << message;
-
+ (*src) << message;
+
THolder<TLogElement> dst = MakeHolder<TLogElement>(std::move(*src));
-
- src.Destroy();
- UNIT_ASSERT(output.Str() == "");
-
- dst.Destroy();
- UNIT_ASSERT(output.Str() == message);
-}
+
+ src.Destroy();
+ UNIT_ASSERT(output.Str() == "");
+
+ dst.Destroy();
+ UNIT_ASSERT(output.Str() == message);
+}
diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp
index 0ccf9e374b..afda2404f5 100644
--- a/library/cpp/logger/thread.cpp
+++ b/library/cpp/logger/thread.cpp
@@ -112,7 +112,7 @@ public:
private:
TLogBackend* Slave_;
- TThreadPool Queue_{"ThreadedLogBack"};
+ TThreadPool Queue_{"ThreadedLogBack"};
const std::function<void()> QueueOverflowCallback_;
};
diff --git a/library/cpp/logger/ut/ya.make b/library/cpp/logger/ut/ya.make
index 2a461c1353..3e990ab8d2 100644
--- a/library/cpp/logger/ut/ya.make
+++ b/library/cpp/logger/ut/ya.make
@@ -12,7 +12,7 @@ SRCDIR(library/cpp/logger)
SRCS(
log_ut.cpp
- element_ut.cpp
+ element_ut.cpp
rotating_file_ut.cpp
composite_ut.cpp
)
diff --git a/library/cpp/threading/task_scheduler/task_scheduler.cpp b/library/cpp/threading/task_scheduler/task_scheduler.cpp
index 174dde4bf7..a3f7827027 100644
--- a/library/cpp/threading/task_scheduler/task_scheduler.cpp
+++ b/library/cpp/threading/task_scheduler/task_scheduler.cpp
@@ -189,8 +189,8 @@ void TTaskScheduler::ChooseFromQueue(TQueueIterator& toWait) {
}
void TTaskScheduler::WorkerFunc(TWorkerThread* thread) {
- TThread::SetCurrentThreadName("TaskSchedWorker");
-
+ TThread::SetCurrentThreadName("TaskSchedWorker");
+
TQueueIterator toWait = Queue_.end();
ITaskRef toDo;
diff --git a/library/cpp/tvmauth/client/misc/threaded_updater.cpp b/library/cpp/tvmauth/client/misc/threaded_updater.cpp
index 5d21ce67a7..c1b3cca5fd 100644
--- a/library/cpp/tvmauth/client/misc/threaded_updater.cpp
+++ b/library/cpp/tvmauth/client/misc/threaded_updater.cpp
@@ -4,7 +4,7 @@
#include <util/string/builder.h>
#include <util/system/spin_wait.h>
-#include <util/system/thread.h>
+#include <util/system/thread.h>
namespace NTvmAuth {
TThreadedUpdaterBase::TThreadedUpdaterBase(TDuration workerAwakingPeriod,
@@ -86,7 +86,7 @@ namespace NTvmAuth {
}
void* TThreadedUpdaterBase::WorkerWrap(void* arg) {
- TThread::SetCurrentThreadName("TicketParserUpd");
+ TThread::SetCurrentThreadName("TicketParserUpd");
TThreadedUpdaterBase& this_ = *reinterpret_cast<TThreadedUpdaterBase*>(arg);
this_.Started_.Signal();
this_.LogDebug("Thread-worker started");
diff --git a/library/python/ya.make b/library/python/ya.make
index 2e1eb6e0e1..2465099743 100644
--- a/library/python/ya.make
+++ b/library/python/ya.make
@@ -191,8 +191,8 @@ RECURSE(
toloka-airflow
toloka-prefect
tools_structured_logs
- thread
- thread/test
+ thread
+ thread/test
tskv
tvmauth
tvm2
diff --git a/util/generic/hash.h b/util/generic/hash.h
index e46db21fa9..e02b8aff18 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -1651,31 +1651,31 @@ public:
const T& at(const TheKey& key) const {
using namespace ::NPrivate;
const_iterator it = find(key);
-
+
if (Y_UNLIKELY(it == end())) {
::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
}
return it->second;
- }
-
+ }
+
template <class TheKey>
T& at(const TheKey& key) {
using namespace ::NPrivate;
iterator it = find(key);
-
+
if (Y_UNLIKELY(it == end())) {
::NPrivate::ThrowKeyNotFoundInHashTableException(MapKeyToString(key));
}
-
+
return it->second;
- }
-
+ }
+
template <class TKey>
size_type count(const TKey& key) const {
return rep.count(key);
}
-
+
template <class TKey>
std::pair<iterator, iterator> equal_range(const TKey& key) {
return rep.equal_range(key);
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index 34d21aebcd..0abcc302f8 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -7,7 +7,7 @@
#include <util/system/align.h>
#include <util/stream/output.h>
-#include <util/ysaveload.h>
+#include <util/ysaveload.h>
namespace NMaybe {
struct TPolicyUndefinedExcept {
@@ -387,31 +387,31 @@ public:
}
void Save(IOutputStream* out) const {
- const bool defined = Defined();
+ const bool defined = Defined();
- ::Save<bool>(out, defined);
+ ::Save<bool>(out, defined);
- if (defined) {
+ if (defined) {
::Save(out, *Data());
- }
- }
-
+ }
+ }
+
void Load(IInputStream* in) {
- bool defined;
+ bool defined;
- ::Load(in, defined);
+ ::Load(in, defined);
- if (defined) {
- if (!Defined()) {
- ConstructInPlace();
- }
+ if (defined) {
+ if (!Defined()) {
+ ConstructInPlace();
+ }
::Load(in, *Data());
- } else {
- Clear();
- }
- }
-
+ } else {
+ Clear();
+ }
+ }
+
void Swap(TMaybe& other) {
if (this->Defined_ == other.Defined_) {
if (this->Defined_) {
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index 09a2d0f140..886c57a5a2 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -198,9 +198,9 @@ TTempBuf::TTempBuf(const TTempBuf&) noexcept = default;
TTempBuf::TTempBuf(TTempBuf&& b) noexcept
: Impl_(std::move(b.Impl_))
-{
-}
-
+{
+}
+
TTempBuf::~TTempBuf() = default;
TTempBuf& TTempBuf::operator=(const TTempBuf& b) noexcept {
@@ -271,9 +271,9 @@ void TTempBuf::Append(const void* data, size_t len) {
}
bool TTempBuf::IsNull() const noexcept {
- return !Impl_;
-}
-
+ return !Impl_;
+}
+
#if 0
#include <util/datetime/cputimer.h>
diff --git a/util/memory/tempbuf_ut.cpp b/util/memory/tempbuf_ut.cpp
index d6bcf9d546..ec3ebb168a 100644
--- a/util/memory/tempbuf_ut.cpp
+++ b/util/memory/tempbuf_ut.cpp
@@ -1,14 +1,14 @@
#include "tempbuf.h"
#include <utility>
-
+
#include <library/cpp/testing/unittest/registar.h>
class TTempBufTest: public TTestBase {
UNIT_TEST_SUITE(TTempBufTest);
UNIT_TEST(TestCreate);
UNIT_TEST(TestOps);
- UNIT_TEST(TestMoveCtor);
+ UNIT_TEST(TestMoveCtor);
UNIT_TEST(TestAppend);
UNIT_TEST(TestProceed);
UNIT_TEST_SUITE_END();
@@ -16,7 +16,7 @@ class TTempBufTest: public TTestBase {
public:
void TestCreate();
void TestOps();
- void TestMoveCtor();
+ void TestMoveCtor();
void TestProceed();
void TestAppend() {
@@ -64,19 +64,19 @@ void TTempBufTest::TestOps() {
UNIT_ASSERT(tmp.Size() >= 201);
UNIT_ASSERT_EQUAL(tmp.Filled(), 0);
}
-
-void TTempBufTest::TestMoveCtor() {
- TTempBuf src;
- UNIT_ASSERT(!src.IsNull());
-
- src.Proceed(10);
-
+
+void TTempBufTest::TestMoveCtor() {
+ TTempBuf src;
+ UNIT_ASSERT(!src.IsNull());
+
+ src.Proceed(10);
+
TTempBuf dst(std::move(src));
-
- UNIT_ASSERT(src.IsNull());
- UNIT_ASSERT(!dst.IsNull());
- UNIT_ASSERT_EQUAL(dst.Filled(), 10);
-}
+
+ UNIT_ASSERT(src.IsNull());
+ UNIT_ASSERT(!dst.IsNull());
+ UNIT_ASSERT_EQUAL(dst.Filled(), 10);
+}
void TTempBufTest::TestProceed() {
TTempBuf src;
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp
index 4041402db9..d97adef5c2 100644
--- a/util/system/mutex.cpp
+++ b/util/system/mutex.cpp
@@ -126,7 +126,7 @@ TMutex::TMutex()
}
TMutex::TMutex(TMutex&&) = default;
-
+
TMutex::~TMutex() = default;
void TMutex::Acquire() noexcept {
diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp
index 05fad02e9b..2e2edf9488 100644
--- a/util/thread/pool.cpp
+++ b/util/thread/pool.cpp
@@ -14,52 +14,52 @@
#include <util/generic/fastqueue.h>
#include <util/stream/output.h>
-#include <util/string/builder.h>
+#include <util/string/builder.h>
#include <util/system/event.h>
#include <util/system/mutex.h>
#include <util/system/atomic.h>
#include <util/system/condvar.h>
-#include <util/system/thread.h>
+#include <util/system/thread.h>
#include <util/datetime/base.h>
#include "factory.h"
#include "pool.h"
-namespace {
- class TThreadNamer {
- public:
- TThreadNamer(const IThreadPool::TParams& params)
- : ThreadName(params.ThreadName_)
- , EnumerateThreads(params.EnumerateThreads_)
- {
- }
-
+namespace {
+ class TThreadNamer {
+ public:
+ TThreadNamer(const IThreadPool::TParams& params)
+ : ThreadName(params.ThreadName_)
+ , EnumerateThreads(params.EnumerateThreads_)
+ {
+ }
+
explicit operator bool() const {
- return !ThreadName.empty();
- }
-
- void SetCurrentThreadName() {
- if (EnumerateThreads) {
- Set(TStringBuilder() << ThreadName << (Index++));
- } else {
- Set(ThreadName);
- }
- }
-
- private:
- void Set(const TString& name) {
- TThread::SetCurrentThreadName(name.c_str());
- }
-
- private:
- TString ThreadName;
- bool EnumerateThreads = false;
- std::atomic<ui64> Index{0};
- };
-}
-
+ return !ThreadName.empty();
+ }
+
+ void SetCurrentThreadName() {
+ if (EnumerateThreads) {
+ Set(TStringBuilder() << ThreadName << (Index++));
+ } else {
+ Set(ThreadName);
+ }
+ }
+
+ private:
+ void Set(const TString& name) {
+ TThread::SetCurrentThreadName(name.c_str());
+ }
+
+ private:
+ TString ThreadName;
+ bool EnumerateThreads = false;
+ std::atomic<ui64> Index{0};
+ };
+}
+
TThreadFactoryHolder::TThreadFactoryHolder() noexcept
: Pool_(SystemThreadFactory())
{
@@ -71,11 +71,11 @@ class TThreadPool::TImpl: public TIntrusiveListItem<TImpl>, public IThreadFactor
using TThreadRef = THolder<IThreadFactory::IThread>;
public:
- inline TImpl(TThreadPool* parent, size_t thrnum, size_t maxqueue, const TParams& params)
+ inline TImpl(TThreadPool* parent, size_t thrnum, size_t maxqueue, const TParams& params)
: Parent_(parent)
- , Blocking(params.Blocking_)
- , Catching(params.Catching_)
- , Namer(params)
+ , Blocking(params.Blocking_)
+ , Catching(params.Catching_)
+ , Namer(params)
, ShouldTerminate(1)
, MaxQueueSize(0)
, ThreadCountExpected(0)
@@ -204,10 +204,10 @@ private:
void DoExecute() override {
THolder<TTsr> tsr(new TTsr(Parent_));
- if (Namer) {
- Namer.SetCurrentThreadName();
- }
-
+ if (Namer) {
+ Namer.SetCurrentThreadName();
+ }
+
while (true) {
IObjectInQueue* job = nullptr;
@@ -227,18 +227,18 @@ private:
QueuePopCond.Signal();
- if (Catching) {
+ if (Catching) {
try {
- try {
- job->Process(*tsr);
- } catch (...) {
- Cdbg << "[mtp queue] " << CurrentExceptionMessage() << Endl;
- }
+ try {
+ job->Process(*tsr);
+ } catch (...) {
+ Cdbg << "[mtp queue] " << CurrentExceptionMessage() << Endl;
+ }
} catch (...) {
// ¯\_(ツ)_/¯
}
- } else {
- job->Process(*tsr);
+ } else {
+ job->Process(*tsr);
}
}
@@ -254,9 +254,9 @@ private:
private:
TThreadPool* Parent_;
- const bool Blocking;
- const bool Catching;
- TThreadNamer Namer;
+ const bool Blocking;
+ const bool Catching;
+ TThreadNamer Namer;
mutable TMutex QueueMutex;
mutable TMutex StopMutex;
TCondVar QueuePushCond;
@@ -360,7 +360,7 @@ bool TThreadPool::Add(IObjectInQueue* obj) {
}
void TThreadPool::Start(size_t thrnum, size_t maxque) {
- Impl_.Reset(new TImpl(this, thrnum, maxque, Params));
+ Impl_.Reset(new TImpl(this, thrnum, maxque, Params));
}
void TThreadPool::Stop() noexcept {
@@ -387,27 +387,27 @@ public:
void DoExecute() noexcept override {
THolder<TThread> This(this);
- if (Impl_->Namer) {
- Impl_->Namer.SetCurrentThreadName();
- }
-
+ if (Impl_->Namer) {
+ Impl_->Namer.SetCurrentThreadName();
+ }
+
{
TTsr tsr(Impl_->Parent_);
IObjectInQueue* obj;
while ((obj = Impl_->WaitForJob()) != nullptr) {
- if (Impl_->Catching) {
+ if (Impl_->Catching) {
try {
- try {
- obj->Process(tsr);
- } catch (...) {
- Cdbg << Impl_->Name() << " " << CurrentExceptionMessage() << Endl;
- }
+ try {
+ obj->Process(tsr);
+ } catch (...) {
+ Cdbg << Impl_->Name() << " " << CurrentExceptionMessage() << Endl;
+ }
} catch (...) {
- // ¯\_(ツ)_/¯
+ // ¯\_(ツ)_/¯
}
- } else {
- obj->Process(tsr);
+ } else {
+ obj->Process(tsr);
}
}
}
@@ -418,10 +418,10 @@ public:
THolder<IThreadFactory::IThread> Thread_;
};
- inline TImpl(TAdaptiveThreadPool* parent, const TParams& params)
+ inline TImpl(TAdaptiveThreadPool* parent, const TParams& params)
: Parent_(parent)
- , Catching(params.Catching_)
- , Namer(params)
+ , Catching(params.Catching_)
+ , Namer(params)
, ThrCount_(0)
, AllDone_(false)
, Obj_(nullptr)
@@ -534,8 +534,8 @@ private:
private:
TAdaptiveThreadPool* Parent_;
- const bool Catching;
- TThreadNamer Namer;
+ const bool Catching;
+ TThreadNamer Namer;
TAtomic ThrCount_;
TMutex Mutex_;
TCondVar CondReady_;
@@ -547,22 +547,22 @@ private:
TDuration IdleTime_;
};
-TThreadPoolBase::TThreadPoolBase(const TParams& params)
- : TThreadFactoryHolder(params.Factory_)
- , Params(params)
+TThreadPoolBase::TThreadPoolBase(const TParams& params)
+ : TThreadFactoryHolder(params.Factory_)
+ , Params(params)
{
}
-#define DEFINE_THREAD_POOL_CTORS(type) \
+#define DEFINE_THREAD_POOL_CTORS(type) \
type::type(const TParams& params) \
: TThreadPoolBase(params) \
{ \
}
-
-DEFINE_THREAD_POOL_CTORS(TThreadPool)
-DEFINE_THREAD_POOL_CTORS(TAdaptiveThreadPool)
-DEFINE_THREAD_POOL_CTORS(TSimpleThreadPool)
-
+
+DEFINE_THREAD_POOL_CTORS(TThreadPool)
+DEFINE_THREAD_POOL_CTORS(TAdaptiveThreadPool)
+DEFINE_THREAD_POOL_CTORS(TSimpleThreadPool)
+
TAdaptiveThreadPool::~TAdaptiveThreadPool() = default;
bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) {
@@ -574,7 +574,7 @@ bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) {
}
void TAdaptiveThreadPool::Start(size_t, size_t) {
- Impl_.Reset(new TImpl(this, Params));
+ Impl_.Reset(new TImpl(this, Params));
}
void TAdaptiveThreadPool::Stop() noexcept {
@@ -614,9 +614,9 @@ void TSimpleThreadPool::Start(size_t thrnum, size_t maxque) {
TAdaptiveThreadPool* adaptive(nullptr);
if (thrnum) {
- tmp.Reset(new TThreadPoolBinder<TThreadPool, TSimpleThreadPool>(this, Params));
+ tmp.Reset(new TThreadPoolBinder<TThreadPool, TSimpleThreadPool>(this, Params));
} else {
- adaptive = new TThreadPoolBinder<TAdaptiveThreadPool, TSimpleThreadPool>(this, Params);
+ adaptive = new TThreadPoolBinder<TAdaptiveThreadPool, TSimpleThreadPool>(this, Params);
tmp.Reset(adaptive);
}
@@ -760,10 +760,10 @@ IThread* IThreadPool::DoCreate() {
return new TPoolThread(this);
}
-THolder<IThreadPool> CreateThreadPool(size_t threadsCount, size_t queueSizeLimit, const TThreadPoolParams& params) {
+THolder<IThreadPool> CreateThreadPool(size_t threadsCount, size_t queueSizeLimit, const TThreadPoolParams& params) {
THolder<IThreadPool> queue;
if (threadsCount > 1) {
- queue.Reset(new TThreadPool(params));
+ queue.Reset(new TThreadPool(params));
} else {
queue.Reset(new TFakeThreadPool());
}
diff --git a/util/thread/pool.h b/util/thread/pool.h
index d1ea3a67cb..79e37050e4 100644
--- a/util/thread/pool.h
+++ b/util/thread/pool.h
@@ -80,66 +80,66 @@ IObjectInQueue* MakeThrFuncObj(T&& func) {
return new TThrFuncObj<std::remove_cv_t<std::remove_reference_t<T>>>(std::forward<T>(func));
}
-struct TThreadPoolParams {
- bool Catching_ = true;
- bool Blocking_ = false;
- IThreadFactory* Factory_ = SystemThreadFactory();
- TString ThreadName_;
- bool EnumerateThreads_ = false;
-
- using TSelf = TThreadPoolParams;
-
- TThreadPoolParams() {
- }
-
- TThreadPoolParams(IThreadFactory* factory)
- : Factory_(factory)
- {
- }
-
- TThreadPoolParams(const TString& name) {
- SetThreadName(name);
- }
-
- TThreadPoolParams(const char* name) {
- SetThreadName(name);
- }
-
- TSelf& SetCatching(bool val) {
- Catching_ = val;
- return *this;
- }
-
- TSelf& SetBlocking(bool val) {
- Blocking_ = val;
- return *this;
- }
-
- TSelf& SetFactory(IThreadFactory* factory) {
- Factory_ = factory;
- return *this;
- }
-
- TSelf& SetThreadName(const TString& name) {
- ThreadName_ = name;
- EnumerateThreads_ = false;
- return *this;
- }
-
- TSelf& SetThreadNamePrefix(const TString& prefix) {
- ThreadName_ = prefix;
- EnumerateThreads_ = true;
- return *this;
- }
-};
-
+struct TThreadPoolParams {
+ bool Catching_ = true;
+ bool Blocking_ = false;
+ IThreadFactory* Factory_ = SystemThreadFactory();
+ TString ThreadName_;
+ bool EnumerateThreads_ = false;
+
+ using TSelf = TThreadPoolParams;
+
+ TThreadPoolParams() {
+ }
+
+ TThreadPoolParams(IThreadFactory* factory)
+ : Factory_(factory)
+ {
+ }
+
+ TThreadPoolParams(const TString& name) {
+ SetThreadName(name);
+ }
+
+ TThreadPoolParams(const char* name) {
+ SetThreadName(name);
+ }
+
+ TSelf& SetCatching(bool val) {
+ Catching_ = val;
+ return *this;
+ }
+
+ TSelf& SetBlocking(bool val) {
+ Blocking_ = val;
+ return *this;
+ }
+
+ TSelf& SetFactory(IThreadFactory* factory) {
+ Factory_ = factory;
+ return *this;
+ }
+
+ TSelf& SetThreadName(const TString& name) {
+ ThreadName_ = name;
+ EnumerateThreads_ = false;
+ return *this;
+ }
+
+ TSelf& SetThreadNamePrefix(const TString& prefix) {
+ ThreadName_ = prefix;
+ EnumerateThreads_ = true;
+ return *this;
+ }
+};
+
/**
* A queue processed simultaneously by several threads
*/
class IThreadPool: public IThreadFactory, public TNonCopyable {
public:
- using TParams = TThreadPoolParams;
-
+ using TParams = TThreadPoolParams;
+
~IThreadPool() override = default;
/**
@@ -255,18 +255,18 @@ public:
}
};
-class TThreadPoolBase: public IThreadPool, public TThreadFactoryHolder {
-public:
- TThreadPoolBase(const TParams& params);
-
-protected:
- TParams Params;
-};
-
+class TThreadPoolBase: public IThreadPool, public TThreadFactoryHolder {
+public:
+ TThreadPoolBase(const TParams& params);
+
+protected:
+ TParams Params;
+};
+
/** queue processed by fixed size thread pool */
-class TThreadPool: public TThreadPoolBase {
+class TThreadPool: public TThreadPoolBase {
public:
- TThreadPool(const TParams& params = {});
+ TThreadPool(const TParams& params = {});
~TThreadPool() override;
bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT;
@@ -290,9 +290,9 @@ private:
* Always create new thread for new task, when all existing threads are busy.
* Maybe dangerous, number of threads is not limited.
*/
-class TAdaptiveThreadPool: public TThreadPoolBase {
+class TAdaptiveThreadPool: public TThreadPoolBase {
public:
- TAdaptiveThreadPool(const TParams& params = {});
+ TAdaptiveThreadPool(const TParams& params = {});
~TAdaptiveThreadPool() override;
/**
@@ -308,15 +308,15 @@ public:
void Stop() noexcept override;
size_t Size() const noexcept override;
-private:
+private:
class TImpl;
THolder<TImpl> Impl_;
};
/** Behave like TThreadPool or TAdaptiveThreadPool, choosen by thrnum parameter of Start() */
-class TSimpleThreadPool: public TThreadPoolBase {
+class TSimpleThreadPool: public TThreadPoolBase {
public:
- TSimpleThreadPool(const TParams& params = {});
+ TSimpleThreadPool(const TParams& params = {});
~TSimpleThreadPool() override;
bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT;
@@ -387,4 +387,4 @@ inline void Delete(THolder<IThreadPool> q) {
* Creates and starts TThreadPool if threadsCount > 1, or TFakeThreadPool otherwise
* You could specify blocking and catching modes for TThreadPool only
*/
-THolder<IThreadPool> CreateThreadPool(size_t threadCount, size_t queueSizeLimit = 0, const IThreadPool::TParams& params = {});
+THolder<IThreadPool> CreateThreadPool(size_t threadCount, size_t queueSizeLimit = 0, const IThreadPool::TParams& params = {});
diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp
index 893770d0c4..189e4865e1 100644
--- a/util/thread/pool_ut.cpp
+++ b/util/thread/pool_ut.cpp
@@ -5,9 +5,9 @@
#include <util/stream/output.h>
#include <util/random/fast.h>
#include <util/system/spinlock.h>
-#include <util/system/thread.h>
-#include <util/system/mutex.h>
-#include <util/system/condvar.h>
+#include <util/system/thread.h>
+#include <util/system/mutex.h>
+#include <util/system/condvar.h>
struct TThreadPoolTest {
TSpinLock Lock;
@@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
Y_UNIT_TEST(TestTThreadPoolBlocking) {
TThreadPoolTest t;
- TThreadPool q(TThreadPool::TParams().SetBlocking(true));
+ TThreadPool q(TThreadPool::TParams().SetBlocking(true));
t.TestAnyQueue(&q, 100);
}
@@ -132,32 +132,32 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
);
UNIT_ASSERT_VALUES_EQUAL(added, false);
}
-
+
Y_UNIT_TEST(TestSafeAddFuncThrows) {
TFailAddQueue queue;
UNIT_CHECK_GENERATED_EXCEPTION(queue.SafeAddFunc([] {}), TThreadPoolException);
}
Y_UNIT_TEST(TestFunctionNotCopied) {
- struct TFailOnCopy {
- TFailOnCopy() {
- }
-
- TFailOnCopy(TFailOnCopy&&) {
- }
-
- TFailOnCopy(const TFailOnCopy&) {
+ struct TFailOnCopy {
+ TFailOnCopy() {
+ }
+
+ TFailOnCopy(TFailOnCopy&&) {
+ }
+
+ TFailOnCopy(const TFailOnCopy&) {
UNIT_FAIL("Don't copy std::function inside TThreadPool");
- }
- };
-
- TThreadPool queue(TThreadPool::TParams().SetBlocking(false).SetCatching(true));
- queue.Start(2);
-
+ }
+ };
+
+ TThreadPool queue(TThreadPool::TParams().SetBlocking(false).SetCatching(true));
+ queue.Start(2);
+
queue.SafeAddFunc([data = TFailOnCopy()]() {});
-
- queue.Stop();
- }
+
+ queue.Stop();
+ }
Y_UNIT_TEST(TestInfoGetters) {
TThreadPool queue;
@@ -178,80 +178,80 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
queue.Stop();
}
-
+
void TestFixedThreadName(IThreadPool& pool, const TString& expectedName) {
- pool.Start(1);
- TString name;
- pool.SafeAddFunc([&name]() {
- name = TThread::CurrentThreadName();
- });
- pool.Stop();
+ pool.Start(1);
+ TString name;
+ pool.SafeAddFunc([&name]() {
+ name = TThread::CurrentThreadName();
+ });
+ pool.Stop();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_EQUAL(name, expectedName);
UNIT_ASSERT_UNEQUAL(TThread::CurrentThreadName(), expectedName);
}
- }
-
- Y_UNIT_TEST(TestFixedThreadName) {
- const TString expectedName = "HelloWorld";
- {
- TThreadPool pool(TThreadPool::TParams().SetBlocking(true).SetCatching(false).SetThreadName(expectedName));
- TestFixedThreadName(pool, expectedName);
- }
- {
- TAdaptiveThreadPool pool(TThreadPool::TParams().SetThreadName(expectedName));
- TestFixedThreadName(pool, expectedName);
- }
- }
-
+ }
+
+ Y_UNIT_TEST(TestFixedThreadName) {
+ const TString expectedName = "HelloWorld";
+ {
+ TThreadPool pool(TThreadPool::TParams().SetBlocking(true).SetCatching(false).SetThreadName(expectedName));
+ TestFixedThreadName(pool, expectedName);
+ }
+ {
+ TAdaptiveThreadPool pool(TThreadPool::TParams().SetThreadName(expectedName));
+ TestFixedThreadName(pool, expectedName);
+ }
+ }
+
void TestEnumeratedThreadName(IThreadPool& pool, const THashSet<TString>& expectedNames) {
- pool.Start(expectedNames.size());
- TMutex lock;
- TCondVar allReady;
- size_t readyCount = 0;
- THashSet<TString> names;
- for (size_t i = 0; i < expectedNames.size(); ++i) {
- pool.SafeAddFunc([&]() {
+ pool.Start(expectedNames.size());
+ TMutex lock;
+ TCondVar allReady;
+ size_t readyCount = 0;
+ THashSet<TString> names;
+ for (size_t i = 0; i < expectedNames.size(); ++i) {
+ pool.SafeAddFunc([&]() {
with_lock (lock) {
- if (++readyCount == expectedNames.size()) {
- allReady.BroadCast();
- } else {
- while (readyCount != expectedNames.size()) {
- allReady.WaitI(lock);
- }
- }
- names.insert(TThread::CurrentThreadName());
- }
- });
- }
- pool.Stop();
+ if (++readyCount == expectedNames.size()) {
+ allReady.BroadCast();
+ } else {
+ while (readyCount != expectedNames.size()) {
+ allReady.WaitI(lock);
+ }
+ }
+ names.insert(TThread::CurrentThreadName());
+ }
+ });
+ }
+ pool.Stop();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_EQUAL(names, expectedNames);
}
- }
-
- Y_UNIT_TEST(TestEnumeratedThreadName) {
- const TString namePrefix = "HelloWorld";
- const THashSet<TString> expectedNames = {
- "HelloWorld0",
- "HelloWorld1",
- "HelloWorld2",
- "HelloWorld3",
- "HelloWorld4",
- "HelloWorld5",
- "HelloWorld6",
- "HelloWorld7",
- "HelloWorld8",
- "HelloWorld9",
- "HelloWorld10",
- };
- {
- TThreadPool pool(TThreadPool::TParams().SetBlocking(true).SetCatching(false).SetThreadNamePrefix(namePrefix));
- TestEnumeratedThreadName(pool, expectedNames);
- }
- {
- TAdaptiveThreadPool pool(TThreadPool::TParams().SetThreadNamePrefix(namePrefix));
- TestEnumeratedThreadName(pool, expectedNames);
- }
- }
+ }
+
+ Y_UNIT_TEST(TestEnumeratedThreadName) {
+ const TString namePrefix = "HelloWorld";
+ const THashSet<TString> expectedNames = {
+ "HelloWorld0",
+ "HelloWorld1",
+ "HelloWorld2",
+ "HelloWorld3",
+ "HelloWorld4",
+ "HelloWorld5",
+ "HelloWorld6",
+ "HelloWorld7",
+ "HelloWorld8",
+ "HelloWorld9",
+ "HelloWorld10",
+ };
+ {
+ TThreadPool pool(TThreadPool::TParams().SetBlocking(true).SetCatching(false).SetThreadNamePrefix(namePrefix));
+ TestEnumeratedThreadName(pool, expectedNames);
+ }
+ {
+ TAdaptiveThreadPool pool(TThreadPool::TParams().SetThreadNamePrefix(namePrefix));
+ TestEnumeratedThreadName(pool, expectedNames);
+ }
+ }
}
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp
index 723c68f391..f1a1c27ae5 100644
--- a/util/ysaveload_ut.cpp
+++ b/util/ysaveload_ut.cpp
@@ -14,7 +14,7 @@
#include <util/generic/vector.h>
#include <util/generic/buffer.h>
#include <util/generic/hash_set.h>
-#include <util/generic/maybe.h>
+#include <util/generic/maybe.h>
#include <util/generic/variant.h>
static inline char* AllocateFromPool(TMemoryPool& pool, size_t len) {
@@ -190,26 +190,26 @@ private:
Save(&S_, deq);
}
- {
- TMaybe<size_t> h(10);
- Save(&S_, h);
- }
-
- {
- TMaybe<size_t> h(20);
- Save(&S_, h);
- }
-
- {
- TMaybe<size_t> h;
- Save(&S_, h);
- }
-
- {
- TMaybe<size_t> h;
- Save(&S_, h);
- }
-
+ {
+ TMaybe<size_t> h(10);
+ Save(&S_, h);
+ }
+
+ {
+ TMaybe<size_t> h(20);
+ Save(&S_, h);
+ }
+
+ {
+ TMaybe<size_t> h;
+ Save(&S_, h);
+ }
+
+ {
+ TMaybe<size_t> h;
+ Save(&S_, h);
+ }
+
{
THashMultiMap<TString, int> mm;
@@ -333,32 +333,32 @@ private:
UNIT_ASSERT_EQUAL(deq[2], 4);
UNIT_ASSERT_EQUAL(deq[3], 5);
}
-
- {
- TMaybe<size_t> h(5);
- Load(&S_, h);
- UNIT_ASSERT_EQUAL(*h, 10);
- }
-
- {
- TMaybe<size_t> h;
- Load(&S_, h);
- UNIT_ASSERT_EQUAL(*h, 20);
- }
-
- {
- TMaybe<size_t> h;
- UNIT_ASSERT(!h);
- Load(&S_, h);
- UNIT_ASSERT(!h);
- }
-
- {
- TMaybe<size_t> h(7);
- UNIT_ASSERT(!!h);
- Load(&S_, h);
- UNIT_ASSERT(!h);
- }
+
+ {
+ TMaybe<size_t> h(5);
+ Load(&S_, h);
+ UNIT_ASSERT_EQUAL(*h, 10);
+ }
+
+ {
+ TMaybe<size_t> h;
+ Load(&S_, h);
+ UNIT_ASSERT_EQUAL(*h, 20);
+ }
+
+ {
+ TMaybe<size_t> h;
+ UNIT_ASSERT(!h);
+ Load(&S_, h);
+ UNIT_ASSERT(!h);
+ }
+
+ {
+ TMaybe<size_t> h(7);
+ UNIT_ASSERT(!!h);
+ Load(&S_, h);
+ UNIT_ASSERT(!h);
+ }
{
THashMultiMap<TString, int> mm;
diff --git a/ydb/library/backup/query_uploader.cpp b/ydb/library/backup/query_uploader.cpp
index c9689c3b2e..470004a299 100644
--- a/ydb/library/backup/query_uploader.cpp
+++ b/ydb/library/backup/query_uploader.cpp
@@ -22,7 +22,7 @@ TUploader::TUploader(const TUploader::TOptions &opts, NYdb::NTable::TTableClient
, RequestLimiter(opts.GetRps(), opts.GetRps())
, Client(client)
{
- TasksQueue = MakeSimpleShared<TThreadPool>(TThreadPool::TParams().SetBlocking(true).SetCatching(true));
+ TasksQueue = MakeSimpleShared<TThreadPool>(TThreadPool::TParams().SetBlocking(true).SetCatching(true));
TasksQueue->Start(opts.InFly, opts.InFly + 1);
}
diff --git a/ydb/library/yql/core/user_data/yql_user_data.cpp b/ydb/library/yql/core/user_data/yql_user_data.cpp
index 11db9c779e..43f8034dad 100644
--- a/ydb/library/yql/core/user_data/yql_user_data.cpp
+++ b/ydb/library/yql/core/user_data/yql_user_data.cpp
@@ -29,7 +29,7 @@ void TUserData::FillFromFolder(
return;
}
root = root.RealPath();
- TDirIterator dir(root, TDirIterator::TOptions(FTS_LOGICAL));
+ TDirIterator dir(root, TDirIterator::TOptions(FTS_LOGICAL));
for (auto file = dir.begin(), end = dir.end(); file != end; ++file) {
if (file->fts_level == FTS_ROOTLEVEL) {
continue;
diff --git a/ydb/public/sdk/cpp/client/ydb_table/impl/request_migrator_ut.cpp b/ydb/public/sdk/cpp/client/ydb_table/impl/request_migrator_ut.cpp
index 714890a324..3f481e49a7 100644
--- a/ydb/public/sdk/cpp/client/ydb_table/impl/request_migrator_ut.cpp
+++ b/ydb/public/sdk/cpp/client/ydb_table/impl/request_migrator_ut.cpp
@@ -76,7 +76,7 @@ private:
class TMigratorClient : public IMigratorClient {
public:
TMigratorClient()
- : Pool_(new TThreadPool(TThreadPool::TParams().SetBlocking(true).SetCatching(false)))
+ : Pool_(new TThreadPool(TThreadPool::TParams().SetBlocking(true).SetCatching(false)))
{
Scheduled_.store(0);
}