aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorishfb <ishfb@yandex-team.ru>2022-02-10 16:48:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:08 +0300
commit069c69f58fd78de3cf2e6eb2304047281e21fb65 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp
parent0170772a2dbf133f32e17ca137ff64790d43831f (diff)
downloadydb-069c69f58fd78de3cf2e6eb2304047281e21fb65.tar.gz
Restoring authorship annotation for <ishfb@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/cgiparam/cgiparam.h18
-rw-r--r--library/cpp/http/server/http.cpp28
-rw-r--r--library/cpp/http/server/http.h48
-rw-r--r--library/cpp/http/server/response.cpp56
-rw-r--r--library/cpp/http/server/response.h76
-rw-r--r--library/cpp/http/server/response_ut.cpp170
-rw-r--r--library/cpp/http/server/ya.make2
-rw-r--r--library/cpp/lwtrace/mon/analytics/ya.make6
-rw-r--r--library/cpp/terminate_handler/sample/ya.make4
-rw-r--r--library/cpp/threading/future/async.cpp2
-rw-r--r--library/cpp/threading/future/async.h38
-rw-r--r--library/cpp/threading/future/async_ut.cpp52
-rw-r--r--library/cpp/threading/future/core/future-inl.h2
-rw-r--r--library/cpp/threading/future/core/future.h2
-rw-r--r--library/cpp/threading/future/future_ut.cpp6
-rw-r--r--library/cpp/threading/future/legacy_future.h48
-rw-r--r--library/cpp/threading/future/legacy_future_ut.cpp48
-rw-r--r--library/cpp/threading/future/ut/ya.make16
-rw-r--r--library/cpp/threading/future/wait/wait-inl.h2
-rw-r--r--library/cpp/threading/future/wait/wait.cpp2
-rw-r--r--library/cpp/threading/future/wait/wait.h2
-rw-r--r--library/cpp/threading/future/ya.make8
22 files changed, 318 insertions, 318 deletions
diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h
index e25eb6e42c..87d1ab0ad4 100644
--- a/library/cpp/cgiparam/cgiparam.h
+++ b/library/cpp/cgiparam/cgiparam.h
@@ -46,11 +46,11 @@ public:
void ScanAddAllUnescaped(const TStringBuf cgiParStr);
void ScanAddAll(const TStringBuf cgiParStr);
- /// Returns the string representation of all the stored parameters
- /**
- * @note The returned string has format <name1>=<value1>&<name2>=<value2>&...
- * @note Names and values in the returned string are CGI-escaped.
- */
+ /// Returns the string representation of all the stored parameters
+ /**
+ * @note The returned string has format <name1>=<value1>&<name2>=<value2>&...
+ * @note Names and values in the returned string are CGI-escaped.
+ */
TString Print() const;
char* Print(char* res) const;
@@ -78,10 +78,10 @@ public:
const auto pair = equal_range(name);
return pair.first != pair.second;
}
- /// Returns value by name
- /**
- * @note The returned value is CGI-unescaped.
- */
+ /// Returns value by name
+ /**
+ * @note The returned value is CGI-unescaped.
+ */
Y_PURE_FUNCTION
const TString& Get(const TStringBuf name, size_t numOfValue = 0) const noexcept;
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index f1d0fcc3a1..128583bdd7 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -771,7 +771,7 @@ THttpServer* TClientRequest::HttpServ() const noexcept {
const TSocket& TClientRequest::Socket() const noexcept {
return Conn_->Socket_;
}
-
+
NAddr::IRemoteAddrRef TClientRequest::GetListenerSockAddrRef() const noexcept {
return Conn_->ListenerSockAddrRef_;
}
@@ -780,21 +780,21 @@ TInstant TClientRequest::AcceptMoment() const noexcept {
return Conn_->AcceptMoment;
}
-/*
- * TRequestReplier
- */
-TRequestReplier::TRequestReplier() {
-}
-
-TRequestReplier::~TRequestReplier() {
-}
-
-bool TRequestReplier::Reply(void* threadSpecificResource) {
- const TReplyParams params = {
+/*
+ * TRequestReplier
+ */
+TRequestReplier::TRequestReplier() {
+}
+
+TRequestReplier::~TRequestReplier() {
+}
+
+bool TRequestReplier::Reply(void* threadSpecificResource) {
+ const TReplyParams params = {
threadSpecificResource, Input(), Output()};
- return DoReply(params);
-}
+ return DoReply(params);
+}
bool TryToBindAddresses(const THttpServerOptions& options, const std::function<void(TSocket)>* callbackOnBoundAddress) {
THttpServerOptions::TBindAddresses addrs;
diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h
index 2993415bfe..b292d38f27 100644
--- a/library/cpp/http/server/http.h
+++ b/library/cpp/http/server/http.h
@@ -99,9 +99,9 @@ private:
THolder<TImpl> Impl_;
};
-/**
- * @deprecated Use TRequestReplier instead
- */
+/**
+ * @deprecated Use TRequestReplier instead
+ */
class TClientRequest: public IObjectInQueue {
friend class THttpServer::TImpl;
@@ -149,28 +149,28 @@ private:
};
class TRequestReplier: public TClientRequest {
-public:
- TRequestReplier();
+public:
+ TRequestReplier();
~TRequestReplier() override;
-
- struct TReplyParams {
- void* ThreadSpecificResource;
- THttpInput& Input;
- THttpOutput& Output;
- };
-
- /*
- * Processes the request after 'connection' been created and 'Headers' been read
- * Returns 'false' if the processing must be continued by the next handler,
- * 'true' otherwise ('this' will be deleted)
- */
- virtual bool DoReply(const TReplyParams& params) = 0;
-
-private:
+
+ struct TReplyParams {
+ void* ThreadSpecificResource;
+ THttpInput& Input;
+ THttpOutput& Output;
+ };
+
+ /*
+ * Processes the request after 'connection' been created and 'Headers' been read
+ * Returns 'false' if the processing must be continued by the next handler,
+ * 'true' otherwise ('this' will be deleted)
+ */
+ virtual bool DoReply(const TReplyParams& params) = 0;
+
+private:
bool Reply(void* threadSpecificResource) final;
-
- using TClientRequest::Input;
- using TClientRequest::Output;
-};
+
+ using TClientRequest::Input;
+ using TClientRequest::Output;
+};
bool TryToBindAddresses(const THttpServerOptions& options, const std::function<void(TSocket)>* callbackOnBoundAddress = nullptr);
diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp
index 52d5f28e5b..52d64c91ce 100644
--- a/library/cpp/http/server/response.cpp
+++ b/library/cpp/http/server/response.cpp
@@ -1,65 +1,65 @@
-#include "response.h"
+#include "response.h"
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/mem.h>
#include <util/string/cast.h>
-
-THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) {
- for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) {
- this->Headers.AddHeader(*i);
- }
- return *this;
-}
-
+
+THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) {
+ for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) {
+ this->Headers.AddHeader(*i);
+ }
+ return *this;
+}
+
THttpResponse& THttpResponse::SetContentType(const TStringBuf& contentType) {
Headers.AddOrReplaceHeader(THttpInputHeader("Content-Type", ToString(contentType)));
return *this;
-}
-
+}
+
void THttpResponse::OutTo(IOutputStream& os) const {
TVector<IOutputStream::TPart> parts;
- const size_t FIRST_LINE_PARTS = 3;
+ const size_t FIRST_LINE_PARTS = 3;
const size_t HEADERS_PARTS = Headers.Count() * 4;
- const size_t CONTENT_PARTS = 5;
- parts.reserve(FIRST_LINE_PARTS + HEADERS_PARTS + CONTENT_PARTS);
-
- // first line
+ const size_t CONTENT_PARTS = 5;
+ parts.reserve(FIRST_LINE_PARTS + HEADERS_PARTS + CONTENT_PARTS);
+
+ // first line
parts.push_back(IOutputStream::TPart(TStringBuf("HTTP/1.1 ")));
parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code)));
parts.push_back(IOutputStream::TPart::CrLf());
-
- // headers
+
+ // headers
for (THttpHeaders::TConstIterator i = Headers.Begin(); i != Headers.End(); ++i) {
parts.push_back(IOutputStream::TPart(i->Name()));
parts.push_back(IOutputStream::TPart(TStringBuf(": ")));
parts.push_back(IOutputStream::TPart(i->Value()));
parts.push_back(IOutputStream::TPart::CrLf());
- }
-
+ }
+
char buf[50];
if (!Content.empty()) {
TMemoryOutput mo(buf, sizeof(buf));
-
+
mo << Content.size();
parts.push_back(IOutputStream::TPart(TStringBuf("Content-Length: ")));
parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf));
parts.push_back(IOutputStream::TPart::CrLf());
- }
-
- // content
+ }
+
+ // content
parts.push_back(IOutputStream::TPart::CrLf());
if (!Content.empty()) {
parts.push_back(IOutputStream::TPart(Content));
- }
-
+ }
+
os.Write(parts.data(), parts.size());
}
template <>
void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) {
resp.OutTo(os);
-}
+}
diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h
index 20751e9096..a75cb85605 100644
--- a/library/cpp/http/server/response.h
+++ b/library/cpp/http/server/response.h
@@ -1,69 +1,69 @@
-#pragma once
+#pragma once
#include <library/cpp/http/misc/httpcodes.h>
#include <library/cpp/http/io/stream.h>
-#include <util/generic/strbuf.h>
-#include <util/string/cast.h>
-
-class THttpHeaders;
+#include <util/generic/strbuf.h>
+#include <util/string/cast.h>
+
+class THttpHeaders;
class IOutputStream;
-
-class THttpResponse {
-public:
+
+class THttpResponse {
+public:
THttpResponse() noexcept
: Code(HTTP_OK)
{
}
explicit THttpResponse(HttpCodes code) noexcept
- : Code(code)
- {
- }
-
+ : Code(code)
+ {
+ }
+
template <typename ValueType>
THttpResponse& AddHeader(const TString& name, const ValueType& value) {
- return AddHeader(THttpInputHeader(name, ToString(value)));
- }
-
- THttpResponse& AddHeader(const THttpInputHeader& header) {
- Headers.AddHeader(header);
-
- return *this;
- }
-
- THttpResponse& AddMultipleHeaders(const THttpHeaders& headers);
-
+ return AddHeader(THttpInputHeader(name, ToString(value)));
+ }
+
+ THttpResponse& AddHeader(const THttpInputHeader& header) {
+ Headers.AddHeader(header);
+
+ return *this;
+ }
+
+ THttpResponse& AddMultipleHeaders(const THttpHeaders& headers);
+
const THttpHeaders& GetHeaders() const {
return Headers;
}
THttpResponse& SetContentType(const TStringBuf& contentType);
- /**
- * @note If @arg content isn't empty its size is automatically added as a
+ /**
+ * @note If @arg content isn't empty its size is automatically added as a
* "Content-Length" header during output to IOutputStream.
* @see IOutputStream& operator << (IOutputStream&, const THttpResponse&)
- */
+ */
THttpResponse& SetContent(const TString& content) {
- Content = content;
+ Content = content;
+
+ return *this;
+ }
- return *this;
- }
-
TString GetContent() const {
return Content;
}
- /**
- * @note If @arg content isn't empty its size is automatically added as a
+ /**
+ * @note If @arg content isn't empty its size is automatically added as a
* "Content-Length" header during output to IOutputStream.
* @see IOutputStream& operator << (IOutputStream&, const THttpResponse&)
- */
+ */
THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) {
return SetContent(content).SetContentType(contentType);
}
-
+
HttpCodes HttpCode() const {
return Code;
}
@@ -75,8 +75,8 @@ public:
void OutTo(IOutputStream& out) const;
-private:
- HttpCodes Code;
- THttpHeaders Headers;
+private:
+ HttpCodes Code;
+ THttpHeaders Headers;
TString Content;
-};
+};
diff --git a/library/cpp/http/server/response_ut.cpp b/library/cpp/http/server/response_ut.cpp
index 6f2914d612..73e2112ad3 100644
--- a/library/cpp/http/server/response_ut.cpp
+++ b/library/cpp/http/server/response_ut.cpp
@@ -1,51 +1,51 @@
-#include "response.h"
-
+#include "response.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/string/cast.h>
Y_UNIT_TEST_SUITE(TestHttpResponse) {
Y_UNIT_TEST(TestCodeOnly) {
UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse()), "HTTP/1.1 200 Ok\r\n\r\n");
- UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_NOT_FOUND)), "HTTP/1.1 404 Not found\r\n\r\n");
- }
-
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_NOT_FOUND)), "HTTP/1.1 404 Not found\r\n\r\n");
+ }
+
Y_UNIT_TEST(TestRedirect) {
- THttpResponse resp = THttpResponse(HTTP_FOUND).AddHeader("Location", "yandex.ru");
- UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), "HTTP/1.1 302 Moved temporarily\r\n"
- "Location: yandex.ru\r\n"
- "\r\n");
- }
-
+ THttpResponse resp = THttpResponse(HTTP_FOUND).AddHeader("Location", "yandex.ru");
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), "HTTP/1.1 302 Moved temporarily\r\n"
+ "Location: yandex.ru\r\n"
+ "\r\n");
+ }
+
Y_UNIT_TEST(TestAddHeader) {
- THttpResponse resp(HTTP_FORBIDDEN);
- resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
- resp.AddHeader("X-Header-2", 10);
- resp.AddHeader("X-Header-3", true);
-
- const char* EXPECTED = "HTTP/1.1 403 Forbidden\r\n"
- "X-Header-1: ValueOne\r\n"
- "X-Header-2: 10\r\n"
- "X-Header-3: 1\r\n"
- "\r\n";
- UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
- }
-
+ THttpResponse resp(HTTP_FORBIDDEN);
+ resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
+ resp.AddHeader("X-Header-2", 10);
+ resp.AddHeader("X-Header-3", true);
+
+ const char* EXPECTED = "HTTP/1.1 403 Forbidden\r\n"
+ "X-Header-1: ValueOne\r\n"
+ "X-Header-2: 10\r\n"
+ "X-Header-3: 1\r\n"
+ "\r\n";
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
+ }
+
Y_UNIT_TEST(TestAddMultipleHeaders) {
- THttpHeaders headers;
- headers.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
- headers.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo"));
- headers.AddHeader(THttpInputHeader("X-Header-3", "ValueThree"));
-
- const char* EXPECTED = "HTTP/1.1 403 Forbidden\r\n"
- "X-Header-1: ValueOne\r\n"
- "X-Header-2: ValueTwo\r\n"
- "X-Header-3: ValueThree\r\n"
- "\r\n";
- UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_FORBIDDEN).AddMultipleHeaders(headers)),
- EXPECTED);
- }
-
+ THttpHeaders headers;
+ headers.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
+ headers.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo"));
+ headers.AddHeader(THttpInputHeader("X-Header-3", "ValueThree"));
+
+ const char* EXPECTED = "HTTP/1.1 403 Forbidden\r\n"
+ "X-Header-1: ValueOne\r\n"
+ "X-Header-2: ValueTwo\r\n"
+ "X-Header-3: ValueThree\r\n"
+ "\r\n";
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse(HTTP_FORBIDDEN).AddMultipleHeaders(headers)),
+ EXPECTED);
+ }
+
Y_UNIT_TEST(TestGetHeaders) {
THttpResponse resp(HTTP_FORBIDDEN);
@@ -66,66 +66,66 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) {
Y_UNIT_TEST(TestSetContent) {
- const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
- "Content-Length: 10\r\n"
- "\r\n"
- "0123456789";
+ const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
+ "Content-Length: 10\r\n"
+ "\r\n"
+ "0123456789";
UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse().SetContent("0123456789")),
- EXPECTED);
- }
-
+ EXPECTED);
+ }
+
Y_UNIT_TEST(TestSetContentWithContentType) {
- const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
- "Content-Type: text/xml\r\n"
- "Content-Length: 28\r\n"
- "\r\n"
- "<xml><tag value=\"1\" /></xml>";
+ const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
+ "Content-Type: text/xml\r\n"
+ "Content-Length: 28\r\n"
+ "\r\n"
+ "<xml><tag value=\"1\" /></xml>";
THttpResponse resp;
resp.SetContent("<xml><tag value=\"1\" /></xml>").SetContentType("text/xml");
- UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
- }
-
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
+ }
+
Y_UNIT_TEST(TestCopyConstructor) {
- THttpResponse resp(HTTP_FORBIDDEN);
- resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"))
- .AddHeader("X-Header-2", "ValueTwo")
- .AddHeader(THttpInputHeader("X-Header-3", "ValueThree"))
+ THttpResponse resp(HTTP_FORBIDDEN);
+ resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"))
+ .AddHeader("X-Header-2", "ValueTwo")
+ .AddHeader(THttpInputHeader("X-Header-3", "ValueThree"))
.SetContent("Some stuff")
.SetContentType("text/plain");
-
- THttpResponse copy = resp;
- UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp));
- }
-
+
+ THttpResponse copy = resp;
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp));
+ }
+
Y_UNIT_TEST(TestAssignment) {
- THttpResponse resp(HTTP_FORBIDDEN);
- resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
- resp.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo"));
- resp.AddHeader(THttpInputHeader("X-Header-3", "ValueThree"));
+ THttpResponse resp(HTTP_FORBIDDEN);
+ resp.AddHeader(THttpInputHeader("X-Header-1", "ValueOne"));
+ resp.AddHeader(THttpInputHeader("X-Header-2", "ValueTwo"));
+ resp.AddHeader(THttpInputHeader("X-Header-3", "ValueThree"));
resp.SetContent("Some stuff").SetContentType("text/plain");
-
+
THttpResponse copy;
- copy = resp;
- UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp));
- }
-
+ copy = resp;
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(copy), ToString(resp));
+ }
+
Y_UNIT_TEST(TestEmptyContent) {
UNIT_ASSERT_STRINGS_EQUAL(ToString(THttpResponse().SetContent("")), "HTTP/1.1 200 Ok\r\n\r\n");
- }
-
+ }
+
Y_UNIT_TEST(TestReturnReference) {
THttpResponse resp;
- UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader("Header1", 1));
- UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader(THttpInputHeader("Header2", "2")));
-
- THttpHeaders headers;
- headers.AddHeader(THttpInputHeader("Header3", "3"));
- headers.AddHeader(THttpInputHeader("Header4", "4"));
- UNIT_ASSERT_EQUAL(&resp, &resp.AddMultipleHeaders(headers));
-
- UNIT_ASSERT_EQUAL(&resp, &resp.SetContent("some stuff"));
+ UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader("Header1", 1));
+ UNIT_ASSERT_EQUAL(&resp, &resp.AddHeader(THttpInputHeader("Header2", "2")));
+
+ THttpHeaders headers;
+ headers.AddHeader(THttpInputHeader("Header3", "3"));
+ headers.AddHeader(THttpInputHeader("Header4", "4"));
+ UNIT_ASSERT_EQUAL(&resp, &resp.AddMultipleHeaders(headers));
+
+ UNIT_ASSERT_EQUAL(&resp, &resp.SetContent("some stuff"));
UNIT_ASSERT_EQUAL(&resp, &resp.SetContent("some other stuff").SetContentType("text/plain"));
- }
+ }
Y_UNIT_TEST(TestSetContentType) {
const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
@@ -139,4 +139,4 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) {
.SetContentType("text/xml");
UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
}
-}
+}
diff --git a/library/cpp/http/server/ya.make b/library/cpp/http/server/ya.make
index d1821c0878..bae6f33306 100644
--- a/library/cpp/http/server/ya.make
+++ b/library/cpp/http/server/ya.make
@@ -13,7 +13,7 @@ SRCS(
http.cpp
http_ex.cpp
options.cpp
- response.cpp
+ response.cpp
)
PEERDIR(
diff --git a/library/cpp/lwtrace/mon/analytics/ya.make b/library/cpp/lwtrace/mon/analytics/ya.make
index 643e499923..c18e23c8e1 100644
--- a/library/cpp/lwtrace/mon/analytics/ya.make
+++ b/library/cpp/lwtrace/mon/analytics/ya.make
@@ -2,9 +2,9 @@ LIBRARY()
OWNER(serxa g:kikimr)
-PEERDIR(
-)
-
+PEERDIR(
+)
+
SRCS(
analytics.cpp
)
diff --git a/library/cpp/terminate_handler/sample/ya.make b/library/cpp/terminate_handler/sample/ya.make
index cae72d1bfd..af089abc65 100644
--- a/library/cpp/terminate_handler/sample/ya.make
+++ b/library/cpp/terminate_handler/sample/ya.make
@@ -1,6 +1,6 @@
RECURSE(
exception
pure-virtual
- rethrow
- segv
+ rethrow
+ segv
)
diff --git a/library/cpp/threading/future/async.cpp b/library/cpp/threading/future/async.cpp
index 6a0564d1cb..ad9b21a2cf 100644
--- a/library/cpp/threading/future/async.cpp
+++ b/library/cpp/threading/future/async.cpp
@@ -1 +1 @@
-#include "async.h"
+#include "async.h"
diff --git a/library/cpp/threading/future/async.h b/library/cpp/threading/future/async.h
index b2952a0548..8543fdd5c6 100644
--- a/library/cpp/threading/future/async.h
+++ b/library/cpp/threading/future/async.h
@@ -1,22 +1,22 @@
-#pragma once
-
-#include "future.h"
-
+#pragma once
+
+#include "future.h"
+
#include <util/generic/function.h>
#include <util/thread/pool.h>
-
-namespace NThreading {
+
+namespace NThreading {
/**
- * @brief Asynchronously executes @arg func in @arg queue returning a future for the result.
- *
- * @arg func should be a callable object with signature T().
- * @arg queue where @arg will be executed
- * @returns For @arg func with signature T() the function returns TFuture<T> unless T is TFuture<U>.
- * In this case the function returns TFuture<U>.
- *
- * If you want to use another queue for execution just write an overload, @see ExtensionExample
- * unittest.
- */
+ * @brief Asynchronously executes @arg func in @arg queue returning a future for the result.
+ *
+ * @arg func should be a callable object with signature T().
+ * @arg queue where @arg will be executed
+ * @returns For @arg func with signature T() the function returns TFuture<T> unless T is TFuture<U>.
+ * In this case the function returns TFuture<U>.
+ *
+ * If you want to use another queue for execution just write an overload, @see ExtensionExample
+ * unittest.
+ */
template <typename Func>
TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) {
auto promise = NewPromise<TFutureType<TFunctionResult<Func>>>();
@@ -24,8 +24,8 @@ namespace NThreading {
NImpl::SetValue(promise, func);
};
queue.SafeAddFunc(std::move(lambda));
-
+
return promise.GetFuture();
}
-
-}
+
+}
diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp
index c2801dbd6e..a3699744e4 100644
--- a/library/cpp/threading/future/async_ut.cpp
+++ b/library/cpp/threading/future/async_ut.cpp
@@ -1,32 +1,32 @@
-#include "async.h"
-
+#include "async.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/ptr.h>
-#include <util/generic/vector.h>
-
-namespace {
+
+#include <util/generic/ptr.h>
+#include <util/generic/vector.h>
+
+namespace {
struct TMySuperTaskQueue {
};
-
-}
-
-namespace NThreading {
+
+}
+
+namespace NThreading {
/* Here we provide an Async overload for TMySuperTaskQueue indide NThreading namespace
- * so that we can call it in the way
- *
- * TMySuperTaskQueue queue;
- * NThreading::Async([](){}, queue);
- *
- * See also ExtensionExample unittest.
- */
+ * so that we can call it in the way
+ *
+ * TMySuperTaskQueue queue;
+ * NThreading::Async([](){}, queue);
+ *
+ * See also ExtensionExample unittest.
+ */
template <typename Func>
TFuture<TFunctionResult<Func>> Async(Func func, TMySuperTaskQueue&) {
return MakeFuture(func());
}
-
-}
-
+
+}
+
Y_UNIT_TEST_SUITE(Async) {
Y_UNIT_TEST(ExtensionExample) {
TMySuperTaskQueue queue;
@@ -34,24 +34,24 @@ Y_UNIT_TEST_SUITE(Async) {
future.Wait();
UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5);
}
-
+
Y_UNIT_TEST(WorksWithIMtpQueue) {
auto queue = MakeHolder<TThreadPool>();
queue->Start(1);
-
+
auto future = NThreading::Async([]() { return 5; }, *queue);
future.Wait();
UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5);
}
-
+
Y_UNIT_TEST(ProperlyDeducesFutureType) {
// Compileability test
auto queue = CreateThreadPool(1);
-
+
NThreading::TFuture<void> f1 = NThreading::Async([]() {}, *queue);
NThreading::TFuture<int> f2 = NThreading::Async([]() { return 5; }, *queue);
NThreading::TFuture<double> f3 = NThreading::Async([]() { return 5.0; }, *queue);
NThreading::TFuture<TVector<int>> f4 = NThreading::Async([]() { return TVector<int>(); }, *queue);
NThreading::TFuture<int> f5 = NThreading::Async([]() { return NThreading::MakeFuture(5); }, *queue);
}
-}
+}
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index bb1aef1ed1..5fd4296a93 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -4,7 +4,7 @@
#error "you should never include future-inl.h directly"
#endif // INCLUDE_FUTURE_INL_H
-namespace NThreading {
+namespace NThreading {
namespace NImpl {
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h
index 3d5570ba5b..2e82bb953e 100644
--- a/library/cpp/threading/future/core/future.h
+++ b/library/cpp/threading/future/core/future.h
@@ -11,7 +11,7 @@
#include <util/system/event.h>
#include <util/system/spinlock.h>
-namespace NThreading {
+namespace NThreading {
////////////////////////////////////////////////////////////////////////////////
struct TFutureException: public yexception {};
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 5cc51fa145..05950a568d 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -5,7 +5,7 @@
#include <list>
#include <type_traits>
-namespace NThreading {
+namespace NThreading {
namespace {
@@ -420,7 +420,7 @@ namespace {
auto promise = NewPromise<TRec>();
promise.SetValue(TRec(1));
-
+
auto future = MakeFuture(TRec(1));
const auto& rec = future.GetValue();
Y_UNUSED(rec);
@@ -637,4 +637,4 @@ namespace {
}
}
-}
+}
diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h
index 4cb446047b..6f1eabad73 100644
--- a/library/cpp/threading/future/legacy_future.h
+++ b/library/cpp/threading/future/legacy_future.h
@@ -1,25 +1,25 @@
-#pragma once
-
+#pragma once
+
#include "fwd.h"
-#include "future.h"
-
+#include "future.h"
+
#include <util/thread/factory.h>
#include <functional>
-namespace NThreading {
+namespace NThreading {
template <typename TR, bool IgnoreException>
class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable {
public:
typedef TR(TFunctionSignature)();
using TFunctionObjectType = std::function<TFunctionSignature>;
using TResult = typename TFunctionObjectType::result_type;
-
+
private:
TFunctionObjectType Func_;
TPromise<TResult> Result_;
THolder<IThreadFactory::IThread> Thread_;
-
+
public:
inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory())
: Func_(func)
@@ -27,24 +27,24 @@ namespace NThreading {
, Thread_(pool->Run(this))
{
}
-
+
inline ~TLegacyFuture() override {
this->Join();
}
-
+
inline TResult Get() {
this->Join();
return Result_.GetValue();
}
-
+
private:
inline void Join() {
if (Thread_) {
Thread_->Join();
Thread_.Destroy();
}
- }
-
+ }
+
template <typename Result, bool IgnoreException_>
struct TExecutor {
static void SetPromise(TPromise<Result>& promise, const TFunctionObjectType& func) {
@@ -54,11 +54,11 @@ namespace NThreading {
} catch (...) {
}
} else {
- promise.SetValue(func());
- }
- }
+ promise.SetValue(func());
+ }
+ }
};
-
+
template <bool IgnoreException_>
struct TExecutor<void, IgnoreException_> {
static void SetPromise(TPromise<void>& promise, const TFunctionObjectType& func) {
@@ -69,15 +69,15 @@ namespace NThreading {
} catch (...) {
}
} else {
- func();
- promise.SetValue();
- }
- }
+ func();
+ promise.SetValue();
+ }
+ }
};
void DoExecute() override {
TExecutor<TResult, IgnoreException>::SetPromise(Result_, Func_);
- }
- };
-
-}
+ }
+ };
+
+}
diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp
index 67c0ea504e..ff63db1725 100644
--- a/library/cpp/threading/future/legacy_future_ut.cpp
+++ b/library/cpp/threading/future/legacy_future_ut.cpp
@@ -1,73 +1,73 @@
-#include "legacy_future.h"
-
+#include "legacy_future.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-namespace NThreading {
+
+namespace NThreading {
Y_UNIT_TEST_SUITE(TLegacyFutureTest) {
int intf() {
return 17;
}
-
+
Y_UNIT_TEST(TestIntFunction) {
TLegacyFuture<int> f((&intf));
UNIT_ASSERT_VALUES_EQUAL(17, f.Get());
}
-
+
static int r;
-
+
void voidf() {
r = 18;
}
-
+
Y_UNIT_TEST(TestVoidFunction) {
r = 0;
TLegacyFuture<> f((&voidf));
f.Get();
UNIT_ASSERT_VALUES_EQUAL(18, r);
}
-
+
struct TSampleClass {
int mValue;
-
+
TSampleClass(int value)
: mValue(value)
{
}
-
+
int Calc() {
return mValue + 1;
}
};
-
+
Y_UNIT_TEST(TestMethod) {
TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3)));
UNIT_ASSERT_VALUES_EQUAL(4, f11.Get());
-
+
TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory());
UNIT_ASSERT_VALUES_EQUAL(4, f12.Get());
-
+
TSampleClass c(5);
-
+
TLegacyFuture<int> f21(std::bind(&TSampleClass::Calc, std::ref(c)));
UNIT_ASSERT_VALUES_EQUAL(6, f21.Get());
-
+
TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory());
UNIT_ASSERT_VALUES_EQUAL(6, f22.Get());
}
-
+
struct TSomeThreadPool: public IThreadFactory {};
-
+
Y_UNIT_TEST(TestFunction) {
std::function<int()> f((&intf));
-
+
UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get());
UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get());
-
+
if (false) {
TSomeThreadPool* q = nullptr;
TLegacyFuture<int>(f, q); // just check compiles, do not start
}
- }
- }
-
-}
+ }
+ }
+
+}
diff --git a/library/cpp/threading/future/ut/ya.make b/library/cpp/threading/future/ut/ya.make
index b2dce89394..566b622370 100644
--- a/library/cpp/threading/future/ut/ya.make
+++ b/library/cpp/threading/future/ut/ya.make
@@ -1,14 +1,14 @@
UNITTEST_FOR(library/cpp/threading/future)
-
+
OWNER(
g:rtmr
ishfb
)
-
-SRCS(
+
+SRCS(
async_ut.cpp
- future_ut.cpp
- legacy_future_ut.cpp
-)
-
-END()
+ future_ut.cpp
+ legacy_future_ut.cpp
+)
+
+END()
diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h
index 27f7528cd9..2753d5446c 100644
--- a/library/cpp/threading/future/wait/wait-inl.h
+++ b/library/cpp/threading/future/wait/wait-inl.h
@@ -4,7 +4,7 @@
#error "you should never include wait-inl.h directly"
#endif // INCLUDE_FUTURE_INL_H
-namespace NThreading {
+namespace NThreading {
namespace NImpl {
template <typename TContainer>
TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) {
diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp
index e538e2876f..a173833a7f 100644
--- a/library/cpp/threading/future/wait/wait.cpp
+++ b/library/cpp/threading/future/wait/wait.cpp
@@ -3,7 +3,7 @@
#include "wait_group.h"
#include "wait_policy.h"
-namespace NThreading {
+namespace NThreading {
namespace {
template <class WaitPolicy>
TFuture<void> WaitGeneric(const TFuture<void>& f1) {
diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h
index 361af5c2b9..6ff7d57baa 100644
--- a/library/cpp/threading/future/wait/wait.h
+++ b/library/cpp/threading/future/wait/wait.h
@@ -7,7 +7,7 @@
#include <util/generic/array_ref.h>
-namespace NThreading {
+namespace NThreading {
namespace NImpl {
template <class TContainer>
using EnableGenericWait = std::enable_if_t<
diff --git a/library/cpp/threading/future/ya.make b/library/cpp/threading/future/ya.make
index aea750cb3e..6591031f46 100644
--- a/library/cpp/threading/future/ya.make
+++ b/library/cpp/threading/future/ya.make
@@ -2,10 +2,10 @@ OWNER(
g:rtmr
)
-LIBRARY()
-
+LIBRARY()
+
SRCS(
- async.cpp
+ async.cpp
core/future.cpp
core/fwd.cpp
fwd.cpp
@@ -15,7 +15,7 @@ SRCS(
wait/wait_policy.cpp
)
-END()
+END()
RECURSE_FOR_TESTS(
mt_ut