aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorelantsev <elantsev@yandex-team.ru>2022-02-10 16:49:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:47 +0300
commitafa1b6e6f8b6ee9f8df080d41bcb19b95c25c261 (patch)
tree0be08f6ef31456c320cbd3f575673be79c911588 /util
parent93452ad7de84fbd34e7ba9a906bf10ce1536d722 (diff)
downloadydb-afa1b6e6f8b6ee9f8df080d41bcb19b95c25c261.tar.gz
Restoring authorship annotation for <elantsev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/datetime/parser_ut.cpp2
-rw-r--r--util/generic/intrlist.h24
-rw-r--r--util/generic/intrlist_ut.cpp344
-rw-r--r--util/network/socket.cpp76
-rw-r--r--util/network/socket.h2
-rw-r--r--util/stream/format.h4
-rw-r--r--util/system/context.cpp4
-rw-r--r--util/system/fasttime.cpp6
8 files changed, 231 insertions, 231 deletions
diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp
index 61364af997..0db7ca4ea4 100644
--- a/util/datetime/parser_ut.cpp
+++ b/util/datetime/parser_ut.cpp
@@ -481,7 +481,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseHttp("Sun Nov 6 08:49:37 1994"),
TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
- UNIT_ASSERT_VALUES_EQUAL(
+ UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseHttp("Mon, 19 Jan 2037 08:49:37 GMT"),
TInstant::ParseIso8601("2037-01-19T08:49:37Z"));
}
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index b5d3f2051b..315e10ed48 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -348,11 +348,11 @@ public:
this->Swap(right);
}
- inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept {
- this->Swap(rhs);
- return *this;
- }
-
+ inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept {
+ this->Swap(rhs);
+ return *this;
+ }
+
inline explicit operator bool() const noexcept {
return !Empty();
}
@@ -611,16 +611,16 @@ public:
this->Clear();
}
- TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept {
+ TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept {
TIntrusiveList<T, Tag>::operator=(std::move(rhs));
- return *this;
- }
-
+ return *this;
+ }
+
public:
inline void Clear() noexcept {
- this->ForEach([](auto* item) {
- D::Destroy(item);
- });
+ this->ForEach([](auto* item) {
+ D::Destroy(item);
+ });
}
inline static void Cut(TIterator begin, TIterator end) noexcept {
diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp
index eff7cdf2ee..6f9649f6ef 100644
--- a/util/generic/intrlist_ut.cpp
+++ b/util/generic/intrlist_ut.cpp
@@ -14,12 +14,12 @@ class TListTest: public TTestBase {
UNIT_TEST(TestQuickSort);
UNIT_TEST(TestCut);
UNIT_TEST(TestAppend);
- UNIT_TEST(TestMoveCtor);
- UNIT_TEST(TestMoveOpEq);
- UNIT_TEST(TestListWithAutoDelete);
- UNIT_TEST(TestListWithAutoDeleteMoveCtor);
- UNIT_TEST(TestListWithAutoDeleteMoveOpEq);
- UNIT_TEST(TestListWithAutoDeleteClear);
+ UNIT_TEST(TestMoveCtor);
+ UNIT_TEST(TestMoveOpEq);
+ UNIT_TEST(TestListWithAutoDelete);
+ UNIT_TEST(TestListWithAutoDeleteMoveCtor);
+ UNIT_TEST(TestListWithAutoDeleteMoveOpEq);
+ UNIT_TEST(TestListWithAutoDeleteClear);
UNIT_TEST(TestSecondTag);
UNIT_TEST_SUITE_END();
@@ -32,12 +32,12 @@ private:
void TestQuickSort();
void TestCut();
void TestAppend();
- void TestMoveCtor();
- void TestMoveOpEq();
- void TestListWithAutoDelete();
- void TestListWithAutoDeleteMoveCtor();
- void TestListWithAutoDeleteMoveOpEq();
- void TestListWithAutoDeleteClear();
+ void TestMoveCtor();
+ void TestMoveOpEq();
+ void TestListWithAutoDelete();
+ void TestListWithAutoDeleteMoveCtor();
+ void TestListWithAutoDeleteMoveOpEq();
+ void TestListWithAutoDeleteClear();
void TestSecondTag();
};
@@ -50,18 +50,18 @@ public:
{
}
- TInt(TInt&& rhs) noexcept
- : Value_(rhs.Value_)
- {
- rhs.Value_ = 0xDEAD;
- }
-
- TInt& operator=(TInt&& rhs) noexcept {
- Value_ = rhs.Value_;
- rhs.Value_ = 0xBEEF;
- return *this;
- }
-
+ TInt(TInt&& rhs) noexcept
+ : Value_(rhs.Value_)
+ {
+ rhs.Value_ = 0xDEAD;
+ }
+
+ TInt& operator=(TInt&& rhs) noexcept {
+ Value_ = rhs.Value_;
+ rhs.Value_ = 0xBEEF;
+ return *this;
+ }
+
inline operator int&() noexcept {
return Value_;
}
@@ -82,12 +82,12 @@ public:
}
}
- //TMyList(const TMyList& rhs) = default;
- TMyList(TMyList&& rhs) noexcept = default;
-
- //operator=(const TMyList& rhs) = default;
- TMyList& operator=(TMyList&& rhs) noexcept = default;
-
+ //TMyList(const TMyList& rhs) = default;
+ TMyList(TMyList&& rhs) noexcept = default;
+
+ //operator=(const TMyList& rhs) = default;
+ TMyList& operator=(TMyList&& rhs) noexcept = default;
+
inline ~TMyList() {
while (!Empty()) {
delete PopBack();
@@ -307,174 +307,174 @@ void TListTest::TestAppend() {
::TestAppend(0, 1);
::TestAppend(1, 1);
}
-
+
template <typename TListType>
-static void CheckList(const TListType& lst) {
- int i = 1;
- for (typename TListType::TConstIterator it = lst.Begin(); it != lst.End(); ++it, ++i) {
- UNIT_ASSERT_EQUAL(*it, i);
- }
-}
-
-void TListTest::TestMoveCtor() {
+static void CheckList(const TListType& lst) {
+ int i = 1;
+ for (typename TListType::TConstIterator it = lst.Begin(); it != lst.End(); ++it, ++i) {
+ UNIT_ASSERT_EQUAL(*it, i);
+ }
+}
+
+void TListTest::TestMoveCtor() {
const int N{42};
TMyList lst{N};
- UNIT_ASSERT(!lst.Empty());
- UNIT_ASSERT_EQUAL(lst.Size(), N);
-
- CheckList(lst);
+ UNIT_ASSERT(!lst.Empty());
+ UNIT_ASSERT_EQUAL(lst.Size(), N);
+
+ CheckList(lst);
TMyList nextLst{std::move(lst)};
- UNIT_ASSERT(lst.Empty());
- CheckList(nextLst);
-}
-
-void TListTest::TestMoveOpEq() {
+ UNIT_ASSERT(lst.Empty());
+ CheckList(nextLst);
+}
+
+void TListTest::TestMoveOpEq() {
const int N{42};
TMyList lst{N};
- UNIT_ASSERT(!lst.Empty());
- UNIT_ASSERT_EQUAL(lst.Size(), N);
- CheckList(lst);
-
+ UNIT_ASSERT(!lst.Empty());
+ UNIT_ASSERT_EQUAL(lst.Size(), N);
+ CheckList(lst);
+
const int M{2};
- TMyList nextLst(M);
- UNIT_ASSERT(!nextLst.Empty());
- UNIT_ASSERT_EQUAL(nextLst.Size(), M);
- CheckList(nextLst);
-
- nextLst = std::move(lst);
- UNIT_ASSERT(!nextLst.Empty());
- UNIT_ASSERT_EQUAL(nextLst.Size(), N);
- CheckList(nextLst);
-}
-
-class TSelfCountingInt: public TIntrusiveListItem<TSelfCountingInt> {
-public:
- TSelfCountingInt(int& counter, int value) noexcept
+ TMyList nextLst(M);
+ UNIT_ASSERT(!nextLst.Empty());
+ UNIT_ASSERT_EQUAL(nextLst.Size(), M);
+ CheckList(nextLst);
+
+ nextLst = std::move(lst);
+ UNIT_ASSERT(!nextLst.Empty());
+ UNIT_ASSERT_EQUAL(nextLst.Size(), N);
+ CheckList(nextLst);
+}
+
+class TSelfCountingInt: public TIntrusiveListItem<TSelfCountingInt> {
+public:
+ TSelfCountingInt(int& counter, int value) noexcept
: Counter_(counter)
, Value_(value)
{
- ++Counter_;
- }
-
- TSelfCountingInt(TSelfCountingInt&& rhs) noexcept
+ ++Counter_;
+ }
+
+ TSelfCountingInt(TSelfCountingInt&& rhs) noexcept
: Counter_(rhs.Counter_)
, Value_(rhs.Value_)
{
- rhs.Value_ = 0xDEAD;
- }
-
- TSelfCountingInt& operator=(TSelfCountingInt&& rhs) noexcept {
- Value_ = rhs.Value_;
- rhs.Value_ = 0xBEEF;
- return *this;
- }
-
- ~TSelfCountingInt() noexcept {
- --Counter_;
- }
-
- inline operator int&() noexcept {
- return Value_;
- }
-
- inline operator const int&() const noexcept {
- return Value_;
- }
-
-private:
- int& Counter_;
- int Value_;
-};
-
-struct TSelfCountingIntDelete {
- static void Destroy(TSelfCountingInt* i) noexcept {
- delete i;
- }
-};
-
-void TListTest::TestListWithAutoDelete() {
+ rhs.Value_ = 0xDEAD;
+ }
+
+ TSelfCountingInt& operator=(TSelfCountingInt&& rhs) noexcept {
+ Value_ = rhs.Value_;
+ rhs.Value_ = 0xBEEF;
+ return *this;
+ }
+
+ ~TSelfCountingInt() noexcept {
+ --Counter_;
+ }
+
+ inline operator int&() noexcept {
+ return Value_;
+ }
+
+ inline operator const int&() const noexcept {
+ return Value_;
+ }
+
+private:
+ int& Counter_;
+ int Value_;
+};
+
+struct TSelfCountingIntDelete {
+ static void Destroy(TSelfCountingInt* i) noexcept {
+ delete i;
+ }
+};
+
+void TListTest::TestListWithAutoDelete() {
using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
- {
+ {
TListType lst;
- UNIT_ASSERT(lst.Empty());
- lst.PushFront(new TSelfCountingInt(counter, 2));
- UNIT_ASSERT_EQUAL(lst.Size(), 1);
- UNIT_ASSERT_EQUAL(counter, 1);
- lst.PushFront(new TSelfCountingInt(counter, 1));
- UNIT_ASSERT_EQUAL(lst.Size(), 2);
- UNIT_ASSERT_EQUAL(counter, 2);
- CheckList(lst);
- }
-
- UNIT_ASSERT_EQUAL(counter, 0);
-}
-
-void TListTest::TestListWithAutoDeleteMoveCtor() {
+ UNIT_ASSERT(lst.Empty());
+ lst.PushFront(new TSelfCountingInt(counter, 2));
+ UNIT_ASSERT_EQUAL(lst.Size(), 1);
+ UNIT_ASSERT_EQUAL(counter, 1);
+ lst.PushFront(new TSelfCountingInt(counter, 1));
+ UNIT_ASSERT_EQUAL(lst.Size(), 2);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ CheckList(lst);
+ }
+
+ UNIT_ASSERT_EQUAL(counter, 0);
+}
+
+void TListTest::TestListWithAutoDeleteMoveCtor() {
using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
- {
+ {
TListType lst;
- lst.PushFront(new TSelfCountingInt(counter, 2));
- lst.PushFront(new TSelfCountingInt(counter, 1));
- UNIT_ASSERT_EQUAL(lst.Size(), 2);
- UNIT_ASSERT_EQUAL(counter, 2);
- CheckList(lst);
-
+ lst.PushFront(new TSelfCountingInt(counter, 2));
+ lst.PushFront(new TSelfCountingInt(counter, 1));
+ UNIT_ASSERT_EQUAL(lst.Size(), 2);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ CheckList(lst);
+
TListType nextList(std::move(lst));
- UNIT_ASSERT_EQUAL(nextList.Size(), 2);
- CheckList(nextList);
- UNIT_ASSERT_EQUAL(counter, 2);
- }
-
- UNIT_ASSERT_EQUAL(counter, 0);
-}
-
-void TListTest::TestListWithAutoDeleteMoveOpEq() {
+ UNIT_ASSERT_EQUAL(nextList.Size(), 2);
+ CheckList(nextList);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ }
+
+ UNIT_ASSERT_EQUAL(counter, 0);
+}
+
+void TListTest::TestListWithAutoDeleteMoveOpEq() {
using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
- {
+ {
TListType lst;
- lst.PushFront(new TSelfCountingInt(counter, 2));
- lst.PushFront(new TSelfCountingInt(counter, 1));
- UNIT_ASSERT_EQUAL(lst.Size(), 2);
- UNIT_ASSERT_EQUAL(counter, 2);
- CheckList(lst);
-
+ lst.PushFront(new TSelfCountingInt(counter, 2));
+ lst.PushFront(new TSelfCountingInt(counter, 1));
+ UNIT_ASSERT_EQUAL(lst.Size(), 2);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ CheckList(lst);
+
TListType nextList;
- UNIT_ASSERT(nextList.Empty());
- nextList = std::move(lst);
- UNIT_ASSERT_EQUAL(nextList.Size(), 2);
- CheckList(nextList);
- UNIT_ASSERT_EQUAL(counter, 2);
- }
-
- UNIT_ASSERT_EQUAL(counter, 0);
-}
-
-void TListTest::TestListWithAutoDeleteClear() {
+ UNIT_ASSERT(nextList.Empty());
+ nextList = std::move(lst);
+ UNIT_ASSERT_EQUAL(nextList.Size(), 2);
+ CheckList(nextList);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ }
+
+ UNIT_ASSERT_EQUAL(counter, 0);
+}
+
+void TListTest::TestListWithAutoDeleteClear() {
using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
- int counter{0};
- {
+ int counter{0};
+ {
TListType lst;
- UNIT_ASSERT(lst.Empty());
- lst.PushFront(new TSelfCountingInt(counter, 2));
- UNIT_ASSERT_EQUAL(lst.Size(), 1);
- UNIT_ASSERT_EQUAL(counter, 1);
- lst.PushFront(new TSelfCountingInt(counter, 1));
- UNIT_ASSERT_EQUAL(lst.Size(), 2);
- UNIT_ASSERT_EQUAL(counter, 2);
- CheckList(lst);
-
- lst.Clear();
- UNIT_ASSERT(lst.Empty());
- UNIT_ASSERT_EQUAL(counter, 0);
- lst.PushFront(new TSelfCountingInt(counter, 1));
- UNIT_ASSERT_EQUAL(lst.Size(), 1);
- }
-
- UNIT_ASSERT_EQUAL(counter, 0);
-}
+ UNIT_ASSERT(lst.Empty());
+ lst.PushFront(new TSelfCountingInt(counter, 2));
+ UNIT_ASSERT_EQUAL(lst.Size(), 1);
+ UNIT_ASSERT_EQUAL(counter, 1);
+ lst.PushFront(new TSelfCountingInt(counter, 1));
+ UNIT_ASSERT_EQUAL(lst.Size(), 2);
+ UNIT_ASSERT_EQUAL(counter, 2);
+ CheckList(lst);
+
+ lst.Clear();
+ UNIT_ASSERT(lst.Empty());
+ UNIT_ASSERT_EQUAL(counter, 0);
+ lst.PushFront(new TSelfCountingInt(counter, 1));
+ UNIT_ASSERT_EQUAL(lst.Size(), 1);
+ }
+
+ UNIT_ASSERT_EQUAL(counter, 0);
+}
struct TSecondTag {};
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 4f6e804346..8a397344c1 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -448,48 +448,48 @@ bool HasLocalAddress(SOCKET socket) {
return IsSame(localAddr, remoteAddr);
}
-namespace {
-#if defined(_linux_)
+namespace {
+#if defined(_linux_)
#if !defined(TCP_FASTOPEN)
#define TCP_FASTOPEN 23
#endif
-#endif
-
-#if defined(TCP_FASTOPEN)
- struct TTcpFastOpenFeature {
- inline TTcpFastOpenFeature()
- : HasFastOpen_(false)
- {
- TSocketHolder tmp(socket(AF_INET, SOCK_STREAM, 0));
- int val = 1;
- int ret = SetSockOpt(tmp, IPPROTO_TCP, TCP_FASTOPEN, val);
- HasFastOpen_ = (ret == 0);
- }
-
- inline void SetFastOpen(SOCKET s, int qlen) const {
- if (HasFastOpen_) {
- CheckedSetSockOpt(s, IPPROTO_TCP, TCP_FASTOPEN, qlen, "setting TCP_FASTOPEN");
- }
- }
-
- static inline const TTcpFastOpenFeature* Instance() noexcept {
- return Singleton<TTcpFastOpenFeature>();
- }
-
- bool HasFastOpen_;
- };
-#endif
-}
-
-void SetTcpFastOpen(SOCKET s, int qlen) {
-#if defined(TCP_FASTOPEN)
- TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen);
-#else
+#endif
+
+#if defined(TCP_FASTOPEN)
+ struct TTcpFastOpenFeature {
+ inline TTcpFastOpenFeature()
+ : HasFastOpen_(false)
+ {
+ TSocketHolder tmp(socket(AF_INET, SOCK_STREAM, 0));
+ int val = 1;
+ int ret = SetSockOpt(tmp, IPPROTO_TCP, TCP_FASTOPEN, val);
+ HasFastOpen_ = (ret == 0);
+ }
+
+ inline void SetFastOpen(SOCKET s, int qlen) const {
+ if (HasFastOpen_) {
+ CheckedSetSockOpt(s, IPPROTO_TCP, TCP_FASTOPEN, qlen, "setting TCP_FASTOPEN");
+ }
+ }
+
+ static inline const TTcpFastOpenFeature* Instance() noexcept {
+ return Singleton<TTcpFastOpenFeature>();
+ }
+
+ bool HasFastOpen_;
+ };
+#endif
+}
+
+void SetTcpFastOpen(SOCKET s, int qlen) {
+#if defined(TCP_FASTOPEN)
+ TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen);
+#else
Y_UNUSED(s);
Y_UNUSED(qlen);
-#endif
-}
-
+#endif
+}
+
static bool IsBlocked(int lasterr) noexcept {
return lasterr == EAGAIN || lasterr == EWOULDBLOCK;
}
@@ -953,7 +953,7 @@ namespace {
insert("localhost.localdomain");
insert("localhost6");
insert("localhost6.localdomain6");
- insert("::1");
+ insert("::1");
}
inline bool IsLocalName(const char* name) const noexcept {
diff --git a/util/network/socket.h b/util/network/socket.h
index 40c8648b40..68cceb0f5f 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -117,7 +117,7 @@ void SetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr, int tos);
int GetSocketToS(SOCKET s);
int GetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr);
void SetSocketPriority(SOCKET s, int priority);
-void SetTcpFastOpen(SOCKET s, int qlen);
+void SetTcpFastOpen(SOCKET s, int qlen);
/**
* Deprecated, consider using HasSocketDataToRead instead.
**/
diff --git a/util/stream/format.h b/util/stream/format.h
index b033208a1b..297725d18e 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -201,7 +201,7 @@ namespace NFormatPrivate {
* @param value Value to output.
* @param width Target total width.
* @param padc Character to use for padding.
- * @see RightPad
+ * @see RightPad
*/
template <typename T>
static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept {
@@ -221,7 +221,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N
*
* Example usage:
* @code
- * stream << RightPad("column1", 10, ' '); // Will output "column1 "
+ * stream << RightPad("column1", 10, ' '); // Will output "column1 "
* @endcode
*
* @param value Value to output.
diff --git a/util/system/context.cpp b/util/system/context.cpp
index ad99309088..f03be0cccc 100644
--- a/util/system/context.cpp
+++ b/util/system/context.cpp
@@ -1,4 +1,4 @@
-#include "compiler.h"
+#include "compiler.h"
#include "defaults.h"
#include "event.h"
#include "thread.h"
@@ -195,7 +195,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
}
void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
- if (Y_LIKELY(__mysetjmp(Buf_) == 0)) {
+ if (Y_LIKELY(__mysetjmp(Buf_) == 0)) {
#if defined(_asan_enabled_) || defined(_tsan_enabled_)
next->San_.BeforeSwitch(&San_);
#endif
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 057a814f0a..5f6ce4e218 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -136,9 +136,9 @@ namespace {
inline void Add(const TSample& s) noexcept {
S_[(C_++) % N] = s;
- if (C_ > 1) {
- ReCalc();
- }
+ if (C_ > 1) {
+ ReCalc();
+ }
}
inline B Predict(A a) const noexcept {