aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorprout <prout@yandex-team.ru>2022-02-10 16:49:43 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:43 +0300
commitd2247f243d31adde8feb765324e40c83c5a90999 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util
parent7b7fa28b9099b7adca890459a699c6ba5eeff4ca (diff)
downloadydb-d2247f243d31adde8feb765324e40c83c5a90999.tar.gz
Restoring authorship annotation for <prout@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/datetime/base.h2
-rw-r--r--util/datetime/base_ut.cpp6
-rw-r--r--util/generic/intrlist.h862
-rw-r--r--util/generic/intrlist_ut.cpp12
-rw-r--r--util/generic/maybe.h84
-rw-r--r--util/generic/maybe_ut.cpp110
-rw-r--r--util/generic/singleton.h30
-rw-r--r--util/memory/tempbuf.cpp6
-rw-r--r--util/memory/tempbuf.h8
-rw-r--r--util/network/address.h6
-rw-r--r--util/network/poller.cpp8
-rw-r--r--util/network/pollerimpl.h56
-rw-r--r--util/network/socket.cpp8
-rw-r--r--util/str_stl.h4
-rw-r--r--util/stream/tempbuf.h6
-rw-r--r--util/system/guard.h20
-rw-r--r--util/system/pipe.cpp8
-rw-r--r--util/system/pipe.h4
-rw-r--r--util/system/rwlock.cpp16
-rw-r--r--util/system/thread.cpp12
-rw-r--r--util/system/thread.h12
21 files changed, 640 insertions, 640 deletions
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 9c2bf17336..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -6,7 +6,7 @@
#include <util/system/platform.h>
#include <util/system/datetime.h>
#include <util/generic/string.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/ylimits.h>
#include <util/generic/utility.h>
#include <util/generic/typetraits.h>
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index 06c84dddbc..afc3f802eb 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -373,10 +373,10 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
Y_UNIT_TEST(TestFromString) {
static const struct T {
- const char* const Str;
- const TDuration::TValue MicroSeconds;
+ const char* const Str;
+ const TDuration::TValue MicroSeconds;
const bool Parseable;
- } tests[] = {
+ } tests[] = {
{"0", 0, true},
{"1", 1000000, true},
{"2s", 2000000, true},
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index 01b06c09ba..b5d3f2051b 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -12,10 +12,10 @@ struct TIntrusiveListDefaultTag {};
*/
template <class T, class Tag = TIntrusiveListDefaultTag>
class TIntrusiveListItem {
-private:
+private:
using TListItem = TIntrusiveListItem<T, Tag>;
-public:
+public:
inline TIntrusiveListItem() noexcept
: Next_(this)
, Prev_(Next_)
@@ -23,93 +23,93 @@ public:
}
inline ~TIntrusiveListItem() {
- Unlink();
- }
+ Unlink();
+ }
-public:
+public:
Y_PURE_FUNCTION inline bool Empty() const noexcept {
- return (Prev_ == this) && (Next_ == this);
- }
+ return (Prev_ == this) && (Next_ == this);
+ }
inline void Unlink() noexcept {
- if (Empty()) {
- return;
+ if (Empty()) {
+ return;
}
- Prev_->SetNext(Next_);
- Next_->SetPrev(Prev_);
+ Prev_->SetNext(Next_);
+ Next_->SetPrev(Prev_);
- SetEnd();
- }
+ SetEnd();
+ }
inline void LinkBefore(TListItem* before) noexcept {
- Unlink();
- LinkBeforeNoUnlink(before);
- }
+ Unlink();
+ LinkBeforeNoUnlink(before);
+ }
inline void LinkBeforeNoUnlink(TListItem* before) noexcept {
- TListItem* const after = before->Prev();
+ TListItem* const after = before->Prev();
- after->SetNext(this);
- SetPrev(after);
- SetNext(before);
- before->SetPrev(this);
- }
+ after->SetNext(this);
+ SetPrev(after);
+ SetNext(before);
+ before->SetPrev(this);
+ }
inline void LinkBefore(TListItem& before) noexcept {
- LinkBefore(&before);
- }
+ LinkBefore(&before);
+ }
inline void LinkAfter(TListItem* after) noexcept {
- Unlink();
- LinkBeforeNoUnlink(after->Next());
- }
+ Unlink();
+ LinkBeforeNoUnlink(after->Next());
+ }
inline void LinkAfter(TListItem& after) noexcept {
- LinkAfter(&after);
- }
+ LinkAfter(&after);
+ }
-public:
+public:
inline TListItem* Prev() noexcept {
- return Prev_;
- }
+ return Prev_;
+ }
inline const TListItem* Prev() const noexcept {
- return Prev_;
- }
+ return Prev_;
+ }
inline TListItem* Next() noexcept {
- return Next_;
- }
+ return Next_;
+ }
inline const TListItem* Next() const noexcept {
- return Next_;
- }
+ return Next_;
+ }
-public:
+public:
inline void SetEnd() noexcept {
- Prev_ = this;
- Next_ = Prev_;
- }
+ Prev_ = this;
+ Next_ = Prev_;
+ }
inline void SetNext(TListItem* item) noexcept {
- Next_ = item;
- }
+ Next_ = item;
+ }
inline void SetPrev(TListItem* item) noexcept {
- Prev_ = item;
- }
+ Prev_ = item;
+ }
-public:
+public:
inline T* Node() noexcept {
- return static_cast<T*>(this);
- }
+ return static_cast<T*>(this);
+ }
inline const T* Node() const noexcept {
- return static_cast<const T*>(this);
- }
+ return static_cast<const T*>(this);
+ }
-private:
+private:
inline TIntrusiveListItem(const TIntrusiveListItem&) = delete;
inline TIntrusiveListItem& operator=(const TIntrusiveListItem&) = delete;
@@ -120,201 +120,201 @@ private:
template <class T, class Tag>
class TIntrusiveList {
-private:
+private:
using TListItem = TIntrusiveListItem<T, Tag>;
- template <class TListItem, class TNode>
- class TIteratorBase {
- public:
+ template <class TListItem, class TNode>
+ class TIteratorBase {
+ public:
using TItem = TListItem;
using TReference = TNode&;
using TPointer = TNode*;
-
+
using iterator_category = std::bidirectional_iterator_tag;
using difference_type = ptrdiff_t;
-
+
using value_type = TNode;
using reference = TReference;
using pointer = TPointer;
-
+
inline TIteratorBase() noexcept
- : Item_(nullptr)
+ : Item_(nullptr)
{
}
- template <class TListItem_, class TNode_>
+ template <class TListItem_, class TNode_>
inline TIteratorBase(const TIteratorBase<TListItem_, TNode_>& right) noexcept
- : Item_(right.Item())
- {
- }
+ : Item_(right.Item())
+ {
+ }
inline TIteratorBase(TItem* item) noexcept
- : Item_(item)
- {
- }
+ : Item_(item)
+ {
+ }
inline TItem* Item() const noexcept {
- return Item_;
- }
+ return Item_;
+ }
inline void Next() noexcept {
- Item_ = Item_->Next();
- }
+ Item_ = Item_->Next();
+ }
inline void Prev() noexcept {
- Item_ = Item_->Prev();
- }
+ Item_ = Item_->Prev();
+ }
- template <class TListItem_, class TNode_>
+ template <class TListItem_, class TNode_>
inline bool operator==(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
- return Item() == right.Item();
- }
+ return Item() == right.Item();
+ }
- template <class TListItem_, class TNode_>
+ template <class TListItem_, class TNode_>
inline bool operator!=(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
- return Item() != right.Item();
- }
+ return Item() != right.Item();
+ }
inline TIteratorBase& operator++() noexcept {
- Next();
+ Next();
- return *this;
- }
+ return *this;
+ }
inline TIteratorBase operator++(int) noexcept {
TIteratorBase ret(*this);
- Next();
+ Next();
- return ret;
- }
+ return ret;
+ }
inline TIteratorBase& operator--() noexcept {
- Prev();
+ Prev();
- return *this;
- }
+ return *this;
+ }
inline TIteratorBase operator--(int) noexcept {
TIteratorBase ret(*this);
- Prev();
+ Prev();
- return ret;
- }
+ return ret;
+ }
inline TReference operator*() const noexcept {
- return *Item_->Node();
- }
+ return *Item_->Node();
+ }
inline TPointer operator->() const noexcept {
- return Item_->Node();
- }
+ return Item_->Node();
+ }
- private:
+ private:
TItem* Item_;
- };
+ };
- template <class TIterator>
- class TReverseIteratorBase {
- public:
+ template <class TIterator>
+ class TReverseIteratorBase {
+ public:
using TItem = typename TIterator::TItem;
using TReference = typename TIterator::TReference;
using TPointer = typename TIterator::TPointer;
-
+
using iterator_category = typename TIterator::iterator_category;
using difference_type = typename TIterator::difference_type;
-
+
using value_type = typename TIterator::value_type;
using reference = typename TIterator::reference;
using pointer = typename TIterator::pointer;
-
+
inline TReverseIteratorBase() noexcept = default;
- template <class TIterator_>
+ template <class TIterator_>
inline TReverseIteratorBase(const TReverseIteratorBase<TIterator_>& right) noexcept
- : Current_(right.Base())
- {
- }
+ : Current_(right.Base())
+ {
+ }
inline explicit TReverseIteratorBase(TIterator item) noexcept
- : Current_(item)
- {
- }
-
+ : Current_(item)
+ {
+ }
+
inline TIterator Base() const noexcept {
- return Current_;
- }
-
+ return Current_;
+ }
+
inline TItem* Item() const noexcept {
- TIterator ret = Current_;
+ TIterator ret = Current_;
+
+ return (--ret).Item();
+ }
- return (--ret).Item();
- }
-
inline void Next() noexcept {
- Current_.Prev();
- }
-
+ Current_.Prev();
+ }
+
inline void Prev() noexcept {
- Current_.Next();
- }
-
- template <class TIterator_>
+ Current_.Next();
+ }
+
+ template <class TIterator_>
inline bool operator==(const TReverseIteratorBase<TIterator_>& right) const noexcept {
- return Base() == right.Base();
- }
-
- template <class TIterator_>
+ return Base() == right.Base();
+ }
+
+ template <class TIterator_>
inline bool operator!=(const TReverseIteratorBase<TIterator_>& right) const noexcept {
- return Base() != right.Base();
- }
-
+ return Base() != right.Base();
+ }
+
inline TReverseIteratorBase& operator++() noexcept {
- Next();
+ Next();
- return *this;
- }
+ return *this;
+ }
inline TReverseIteratorBase operator++(int) noexcept {
TReverseIteratorBase ret(*this);
- Next();
+ Next();
- return ret;
- }
+ return ret;
+ }
inline TReverseIteratorBase& operator--() noexcept {
- Prev();
+ Prev();
- return *this;
- }
+ return *this;
+ }
inline TReverseIteratorBase operator--(int) noexcept {
TReverseIteratorBase ret(*this);
- Prev();
+ Prev();
- return ret;
- }
+ return ret;
+ }
inline TReference operator*() const noexcept {
- TIterator ret = Current_;
+ TIterator ret = Current_;
+
+ return *--ret;
+ }
- return *--ret;
- }
-
inline TPointer operator->() const noexcept {
- TIterator ret = Current_;
+ TIterator ret = Current_;
+
+ return &*--ret;
+ }
- return &*--ret;
- }
-
- private:
- TIterator Current_;
- };
+ private:
+ TIterator Current_;
+ };
-public:
+public:
using TIterator = TIteratorBase<TListItem, T>;
using TConstIterator = TIteratorBase<const TListItem, const T>;
@@ -326,28 +326,28 @@ public:
using reverse_iterator = TReverseIterator;
using const_reverse_iterator = TConstReverseIterator;
-
-public:
+
+public:
inline void Swap(TIntrusiveList& right) noexcept {
- TIntrusiveList temp;
+ TIntrusiveList temp;
- temp.Append(right);
+ temp.Append(right);
Y_ASSERT(right.Empty());
- right.Append(*this);
+ right.Append(*this);
Y_ASSERT(this->Empty());
- this->Append(temp);
+ this->Append(temp);
Y_ASSERT(temp.Empty());
- }
+ }
-public:
+public:
inline TIntrusiveList() noexcept = default;
-
+
inline ~TIntrusiveList() = default;
inline TIntrusiveList(TIntrusiveList&& right) noexcept {
- this->Swap(right);
- }
-
+ this->Swap(right);
+ }
+
inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept {
this->Swap(rhs);
return *this;
@@ -358,235 +358,235 @@ public:
}
Y_PURE_FUNCTION inline bool Empty() const noexcept {
- return End_.Empty();
- }
+ return End_.Empty();
+ }
inline size_t Size() const noexcept {
return std::distance(Begin(), End());
- }
+ }
inline void Remove(TListItem* item) noexcept {
item->Unlink();
}
inline void Clear() noexcept {
- End_.Unlink();
- }
+ End_.Unlink();
+ }
-public:
+public:
inline TIterator Begin() noexcept {
- return ++End();
- }
+ return ++End();
+ }
inline TIterator End() noexcept {
return TIterator(&End_);
- }
+ }
inline TConstIterator Begin() const noexcept {
- return ++End();
- }
+ return ++End();
+ }
inline TConstIterator End() const noexcept {
return TConstIterator(&End_);
- }
+ }
inline TReverseIterator RBegin() noexcept {
return TReverseIterator(End());
- }
+ }
inline TReverseIterator REnd() noexcept {
return TReverseIterator(Begin());
- }
+ }
inline TConstReverseIterator RBegin() const noexcept {
return TConstReverseIterator(End());
- }
+ }
inline TConstReverseIterator REnd() const noexcept {
return TConstReverseIterator(Begin());
- }
+ }
inline TConstIterator CBegin() const noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline TConstIterator CEnd() const noexcept {
- return End();
- }
-
+ return End();
+ }
+
inline TConstReverseIterator CRBegin() const noexcept {
- return RBegin();
- }
-
+ return RBegin();
+ }
+
inline TConstReverseIterator CREnd() const noexcept {
- return REnd();
- }
-
-public:
+ return REnd();
+ }
+
+public:
inline iterator begin() noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline iterator end() noexcept {
- return End();
- }
-
+ return End();
+ }
+
inline const_iterator begin() const noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline const_iterator end() const noexcept {
- return End();
- }
-
+ return End();
+ }
+
inline reverse_iterator rbegin() noexcept {
- return RBegin();
- }
-
+ return RBegin();
+ }
+
inline reverse_iterator rend() noexcept {
- return REnd();
- }
-
+ return REnd();
+ }
+
inline const_iterator cbegin() const noexcept {
- return CBegin();
- }
-
+ return CBegin();
+ }
+
inline const_iterator cend() const noexcept {
- return CEnd();
- }
-
+ return CEnd();
+ }
+
inline const_reverse_iterator crbegin() const noexcept {
- return CRBegin();
- }
-
+ return CRBegin();
+ }
+
inline const_reverse_iterator crend() const noexcept {
- return CREnd();
- }
-
-public:
+ return CREnd();
+ }
+
+public:
inline T* Back() noexcept {
- return End_.Prev()->Node();
- }
-
+ return End_.Prev()->Node();
+ }
+
inline T* Front() noexcept {
- return End_.Next()->Node();
- }
-
+ return End_.Next()->Node();
+ }
+
inline const T* Back() const noexcept {
- return End_.Prev()->Node();
- }
-
+ return End_.Prev()->Node();
+ }
+
inline const T* Front() const noexcept {
- return End_.Next()->Node();
- }
-
+ return End_.Next()->Node();
+ }
+
inline void PushBack(TListItem* item) noexcept {
- item->LinkBefore(End_);
- }
+ item->LinkBefore(End_);
+ }
inline void PushFront(TListItem* item) noexcept {
- item->LinkAfter(End_);
- }
+ item->LinkAfter(End_);
+ }
inline T* PopBack() noexcept {
- TListItem* const ret = End_.Prev();
+ TListItem* const ret = End_.Prev();
- ret->Unlink();
+ ret->Unlink();
- return ret->Node();
- }
+ return ret->Node();
+ }
inline T* PopFront() noexcept {
- TListItem* const ret = End_.Next();
+ TListItem* const ret = End_.Next();
- ret->Unlink();
+ ret->Unlink();
- return ret->Node();
- }
+ return ret->Node();
+ }
inline void Append(TIntrusiveList& list) noexcept {
- Cut(list.Begin(), list.End(), End());
- }
-
+ Cut(list.Begin(), list.End(), End());
+ }
+
inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
- if (begin == end) {
- return;
+ if (begin == end) {
+ return;
}
- TListItem* const cutFront = begin.Item();
- TListItem* const gapBack = end.Item();
+ TListItem* const cutFront = begin.Item();
+ TListItem* const gapBack = end.Item();
- TListItem* const gapFront = cutFront->Prev();
- TListItem* const cutBack = gapBack->Prev();
+ TListItem* const gapFront = cutFront->Prev();
+ TListItem* const cutBack = gapBack->Prev();
- gapFront->SetNext(gapBack);
- gapBack->SetPrev(gapFront);
+ gapFront->SetNext(gapBack);
+ gapBack->SetPrev(gapFront);
- TListItem* const pasteBack = pasteBefore.Item();
- TListItem* const pasteFront = pasteBack->Prev();
+ TListItem* const pasteBack = pasteBefore.Item();
+ TListItem* const pasteFront = pasteBack->Prev();
- pasteFront->SetNext(cutFront);
- cutFront->SetPrev(pasteFront);
+ pasteFront->SetNext(cutFront);
+ cutFront->SetPrev(pasteFront);
- cutBack->SetNext(pasteBack);
- pasteBack->SetPrev(cutBack);
- }
+ cutBack->SetNext(pasteBack);
+ pasteBack->SetPrev(cutBack);
+ }
-public:
- template <class TFunctor>
+public:
+ template <class TFunctor>
inline void ForEach(TFunctor&& functor) {
- TIterator i = Begin();
+ TIterator i = Begin();
- while (i != End()) {
- functor(&*(i++));
- }
- }
+ while (i != End()) {
+ functor(&*(i++));
+ }
+ }
- template <class TFunctor>
+ template <class TFunctor>
inline void ForEach(TFunctor&& functor) const {
- TConstIterator i = Begin();
+ TConstIterator i = Begin();
- while (i != End()) {
- functor(&*(i++));
+ while (i != End()) {
+ functor(&*(i++));
}
- }
+ }
- template <class TComparer>
+ template <class TComparer>
inline void QuickSort(TComparer&& comparer) {
- if (Begin() == End() || ++Begin() == End()) {
- return;
- }
-
- T* const pivot = PopFront();
- TIntrusiveList bigger;
- TIterator i = Begin();
-
- while (i != End()) {
- if (comparer(*pivot, *i)) {
- bigger.PushBack(&*i++);
- } else {
- ++i;
+ if (Begin() == End() || ++Begin() == End()) {
+ return;
+ }
+
+ T* const pivot = PopFront();
+ TIntrusiveList bigger;
+ TIterator i = Begin();
+
+ while (i != End()) {
+ if (comparer(*pivot, *i)) {
+ bigger.PushBack(&*i++);
+ } else {
+ ++i;
}
- }
+ }
- this->QuickSort(comparer);
- bigger.QuickSort(comparer);
+ this->QuickSort(comparer);
+ bigger.QuickSort(comparer);
- PushBack(pivot);
- Append(bigger);
- }
+ PushBack(pivot);
+ Append(bigger);
+ }
-private:
+private:
inline TIntrusiveList(const TIntrusiveList&) = delete;
inline TIntrusiveList& operator=(const TIntrusiveList&) = delete;
private:
- TListItem End_;
+ TListItem End_;
};
template <class T, class D, class Tag>
class TIntrusiveListWithAutoDelete: public TIntrusiveList<T, Tag> {
-public:
+public:
using TIterator = typename TIntrusiveList<T, Tag>::TIterator;
using TConstIterator = typename TIntrusiveList<T, Tag>::TConstIterator;
@@ -598,39 +598,39 @@ public:
using reverse_iterator = TReverseIterator;
using const_reverse_iterator = TConstReverseIterator;
-
-public:
+
+public:
inline TIntrusiveListWithAutoDelete() noexcept = default;
-
+
inline TIntrusiveListWithAutoDelete(TIntrusiveListWithAutoDelete&& right) noexcept
: TIntrusiveList<T, Tag>(std::move(right))
- {
- }
-
+ {
+ }
+
inline ~TIntrusiveListWithAutoDelete() {
- this->Clear();
- }
-
+ this->Clear();
+ }
+
TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept {
TIntrusiveList<T, Tag>::operator=(std::move(rhs));
return *this;
}
-public:
+public:
inline void Clear() noexcept {
this->ForEach([](auto* item) {
D::Destroy(item);
});
- }
+ }
inline static void Cut(TIterator begin, TIterator end) noexcept {
TIntrusiveListWithAutoDelete<T, D, Tag> temp;
- Cut(begin, end, temp.End());
- }
-
+ Cut(begin, end, temp.End());
+ }
+
inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
TIntrusiveList<T, Tag>::Cut(begin, end, pasteBefore);
- }
+ }
};
/*
@@ -638,54 +638,54 @@ public:
*/
template <class T, class Tag = TIntrusiveListDefaultTag>
class TIntrusiveSListItem {
-private:
+private:
using TListItem = TIntrusiveSListItem<T, Tag>;
-public:
+public:
inline TIntrusiveSListItem() noexcept
- : Next_(nullptr)
+ : Next_(nullptr)
{
- }
+ }
inline ~TIntrusiveSListItem() = default;
inline bool IsEnd() const noexcept {
- return Next_ == nullptr;
+ return Next_ == nullptr;
}
inline TListItem* Next() noexcept {
- return Next_;
- }
+ return Next_;
+ }
inline const TListItem* Next() const noexcept {
- return Next_;
- }
+ return Next_;
+ }
inline void SetNext(TListItem* item) noexcept {
- Next_ = item;
- }
+ Next_ = item;
+ }
-public:
+public:
inline T* Node() noexcept {
- return static_cast<T*>(this);
- }
+ return static_cast<T*>(this);
+ }
inline const T* Node() const noexcept {
- return static_cast<const T*>(this);
- }
+ return static_cast<const T*>(this);
+ }
-private:
+private:
TListItem* Next_;
};
template <class T, class Tag>
class TIntrusiveSList {
-private:
+private:
using TListItem = TIntrusiveSListItem<T, Tag>;
-public:
- template <class TListItem, class TNode>
- class TIteratorBase {
+public:
+ template <class TListItem, class TNode>
+ class TIteratorBase {
public:
using TItem = TListItem;
using TReference = TNode&;
@@ -698,175 +698,175 @@ public:
using iterator_category = std::forward_iterator_tag;
inline TIteratorBase(TListItem* item) noexcept
- : Item_(item)
- {
- }
+ : Item_(item)
+ {
+ }
inline void Next() noexcept {
- Item_ = Item_->Next();
- }
+ Item_ = Item_->Next();
+ }
inline bool operator==(const TIteratorBase& right) const noexcept {
- return Item_ == right.Item_;
- }
+ return Item_ == right.Item_;
+ }
inline bool operator!=(const TIteratorBase& right) const noexcept {
- return Item_ != right.Item_;
- }
+ return Item_ != right.Item_;
+ }
inline TIteratorBase& operator++() noexcept {
- Next();
+ Next();
- return *this;
- }
+ return *this;
+ }
inline TIteratorBase operator++(int) noexcept {
- TIteratorBase ret(*this);
+ TIteratorBase ret(*this);
- Next();
+ Next();
- return ret;
- }
+ return ret;
+ }
inline TNode& operator*() noexcept {
- return *Item_->Node();
- }
+ return *Item_->Node();
+ }
inline TNode* operator->() noexcept {
- return Item_->Node();
- }
+ return Item_->Node();
+ }
- private:
+ private:
TListItem* Item_;
- };
+ };
-public:
+public:
using TIterator = TIteratorBase<TListItem, T>;
using TConstIterator = TIteratorBase<const TListItem, const T>;
using iterator = TIterator;
using const_iterator = TConstIterator;
-public:
+public:
inline TIntrusiveSList() noexcept
- : Begin_(nullptr)
+ : Begin_(nullptr)
{
- }
+ }
inline void Swap(TIntrusiveSList& right) noexcept {
DoSwap(Begin_, right.Begin_);
- }
+ }
inline explicit operator bool() const noexcept {
return !Empty();
}
Y_PURE_FUNCTION inline bool Empty() const noexcept {
- return Begin_ == nullptr;
- }
+ return Begin_ == nullptr;
+ }
inline size_t Size() const noexcept {
return std::distance(Begin(), End());
- }
+ }
inline void Clear() noexcept {
- Begin_ = nullptr;
- }
+ Begin_ = nullptr;
+ }
inline TIterator Begin() noexcept {
return TIterator(Begin_);
- }
+ }
inline TIterator End() noexcept {
- return TIterator(nullptr);
- }
+ return TIterator(nullptr);
+ }
inline TConstIterator Begin() const noexcept {
return TConstIterator(Begin_);
- }
+ }
inline TConstIterator End() const noexcept {
- return TConstIterator(nullptr);
- }
+ return TConstIterator(nullptr);
+ }
inline TConstIterator CBegin() const noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline TConstIterator CEnd() const noexcept {
- return End();
- }
-
+ return End();
+ }
+
//compat methods
inline iterator begin() noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline iterator end() noexcept {
- return End();
- }
-
+ return End();
+ }
+
inline const_iterator begin() const noexcept {
- return Begin();
- }
-
+ return Begin();
+ }
+
inline const_iterator end() const noexcept {
- return End();
- }
-
+ return End();
+ }
+
inline const_iterator cbegin() const noexcept {
- return CBegin();
- }
-
+ return CBegin();
+ }
+
inline const_iterator cend() const noexcept {
- return CEnd();
- }
-
+ return CEnd();
+ }
+
inline T* Front() noexcept {
Y_ASSERT(Begin_);
- return Begin_->Node();
- }
-
+ return Begin_->Node();
+ }
+
inline const T* Front() const noexcept {
Y_ASSERT(Begin_);
- return Begin_->Node();
- }
-
+ return Begin_->Node();
+ }
+
inline void PushFront(TListItem* item) noexcept {
- item->SetNext(Begin_);
- Begin_ = item;
- }
+ item->SetNext(Begin_);
+ Begin_ = item;
+ }
inline T* PopFront() noexcept {
Y_ASSERT(Begin_);
- TListItem* const ret = Begin_;
- Begin_ = Begin_->Next();
+ TListItem* const ret = Begin_;
+ Begin_ = Begin_->Next();
+
+ return ret->Node();
+ }
- return ret->Node();
- }
-
inline void Reverse() noexcept {
- TIntrusiveSList temp;
-
- while (!Empty()) {
- temp.PushFront(PopFront());
+ TIntrusiveSList temp;
+
+ while (!Empty()) {
+ temp.PushFront(PopFront());
}
- this->Swap(temp);
- }
+ this->Swap(temp);
+ }
- template <class TFunctor>
+ template <class TFunctor>
inline void ForEach(TFunctor&& functor) const noexcept(noexcept(functor(std::declval<TListItem>().Node()))) {
- TListItem* i = Begin_;
+ TListItem* i = Begin_;
- while (i) {
- TListItem* const next = i->Next();
- functor(i->Node());
- i = next;
+ while (i) {
+ TListItem* const next = i->Next();
+ functor(i->Node());
+ i = next;
}
- }
+ }
-private:
+private:
TListItem* Begin_;
};
diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp
index 25892b9cab..eff7cdf2ee 100644
--- a/util/generic/intrlist_ut.cpp
+++ b/util/generic/intrlist_ut.cpp
@@ -95,9 +95,9 @@ public:
}
};
-struct TIntGreater: private TGreater<int> {
+struct TIntGreater: private TGreater<int> {
inline bool operator()(const TInt& l, const TInt& r) const noexcept {
- return TGreater<int>::operator()(l, r);
+ return TGreater<int>::operator()(l, r);
}
};
@@ -105,7 +105,7 @@ void TListTest::TestQuickSort() {
TMyList l(1000);
size_t c = 0;
- l.QuickSort(TIntGreater());
+ l.QuickSort(TIntGreater());
UNIT_ASSERT_EQUAL(l.Size(), 1000);
@@ -137,9 +137,9 @@ void TListTest::TestRIterate() {
TMyList l(1000);
size_t c = 1000;
- UNIT_ASSERT_EQUAL(l.RBegin(), TMyList::TReverseIterator(l.End()));
- UNIT_ASSERT_EQUAL(l.REnd(), TMyList::TReverseIterator(l.Begin()));
-
+ UNIT_ASSERT_EQUAL(l.RBegin(), TMyList::TReverseIterator(l.End()));
+ UNIT_ASSERT_EQUAL(l.REnd(), TMyList::TReverseIterator(l.Begin()));
+
for (TMyList::TReverseIterator it = l.RBegin(); it != l.REnd(); ++it) {
UNIT_ASSERT_EQUAL(*it, (int)c--);
}
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index 6a1a048bc6..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -233,11 +233,11 @@ public:
template <class U = T>
std::enable_if_t<TAssignableFromAny<U>::value, TMaybe&> operator=(U&& right) {
- if (Defined()) {
+ if (Defined()) {
*Data() = std::forward<U>(right);
- } else {
+ } else {
Init(std::forward<U>(right));
- }
+ }
return *this;
}
@@ -245,7 +245,7 @@ public:
std::enable_if_t<TCopyAssignable<U>::value,
TMaybe&>
operator=(const TMaybe<U, Policy>& right) {
- if (right.Defined()) {
+ if (right.Defined()) {
if (Defined()) {
*Data() = right.GetRef();
} else {
@@ -285,44 +285,44 @@ public:
}
void Clear() noexcept {
- if (Defined()) {
+ if (Defined()) {
this->Defined_ = false;
Data()->~T();
- }
+ }
}
constexpr bool Defined() const noexcept {
return this->Defined_;
- }
+ }
Y_PURE_FUNCTION constexpr bool Empty() const noexcept {
- return !Defined();
+ return !Defined();
}
void CheckDefined() const {
if (Y_UNLIKELY(!Defined())) {
Policy::OnEmpty(typeid(TValueType));
- }
- }
-
+ }
+ }
+
const T* Get() const noexcept {
return Defined() ? Data() : nullptr;
- }
-
+ }
+
T* Get() noexcept {
return Defined() ? Data() : nullptr;
- }
-
+ }
+
constexpr const T& GetRef() const& {
CheckDefined();
- return *Data();
+ return *Data();
}
constexpr T& GetRef() & {
CheckDefined();
- return *Data();
+ return *Data();
}
constexpr const T&& GetRef() const&& {
@@ -338,11 +338,11 @@ public:
}
constexpr const T& operator*() const& {
- return GetRef();
- }
+ return GetRef();
+ }
constexpr T& operator*() & {
- return GetRef();
+ return GetRef();
}
constexpr const T&& operator*() const&& {
@@ -354,29 +354,29 @@ public:
}
constexpr const T* operator->() const {
- return &GetRef();
+ return &GetRef();
}
constexpr T* operator->() {
- return &GetRef();
- }
-
+ return &GetRef();
+ }
+
constexpr const T& GetOrElse(const T& elseValue) const {
- return Defined() ? *Data() : elseValue;
- }
-
+ return Defined() ? *Data() : elseValue;
+ }
+
constexpr T& GetOrElse(T& elseValue) {
- return Defined() ? *Data() : elseValue;
- }
-
+ return Defined() ? *Data() : elseValue;
+ }
+
constexpr const TMaybe& OrElse(const TMaybe& elseValue) const noexcept {
- return Defined() ? *this : elseValue;
- }
-
+ return Defined() ? *this : elseValue;
+ }
+
constexpr TMaybe& OrElse(TMaybe& elseValue) {
- return Defined() ? *this : elseValue;
- }
-
+ return Defined() ? *this : elseValue;
+ }
+
template <typename U>
TMaybe<U, Policy> Cast() const {
return Defined() ? TMaybe<U, Policy>(*Data()) : TMaybe<U, Policy>();
@@ -432,20 +432,20 @@ public:
Swap(other);
}
-private:
+private:
constexpr const T* Data() const noexcept {
return std::addressof(this->Data_);
- }
-
+ }
+
constexpr T* Data() noexcept {
return std::addressof(this->Data_);
- }
-
+ }
+
template <typename... Args>
void Init(Args&&... args) {
new (Data()) T(std::forward<Args>(args)...);
this->Defined_ = true;
- }
+ }
};
template <class T>
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index 59e17a687a..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -8,16 +8,16 @@
class TIncrementOnDestroy {
private:
int* Ptr_;
-
+
public:
TIncrementOnDestroy(int* ptr) noexcept
: Ptr_(ptr)
- {
+ {
}
-
+
~TIncrementOnDestroy() {
++*Ptr_;
- }
+ }
};
Y_UNIT_TEST_SUITE(TMaybeTest) {
@@ -54,80 +54,80 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
Y_UNIT_TEST(TTestConstructorDestructor) {
- int a = 0;
- int b = 0;
+ int a = 0;
+ int b = 0;
TMaybe<TIncrementOnDestroy>();
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
- TMaybe<TIncrementOnDestroy>(TIncrementOnDestroy(&a));
- b += 2;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ TMaybe<TIncrementOnDestroy>(TIncrementOnDestroy(&a));
+ b += 2;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
{
- TMaybe<TIncrementOnDestroy> m1 = TIncrementOnDestroy(&a);
- b += 1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ TMaybe<TIncrementOnDestroy> m1 = TIncrementOnDestroy(&a);
+ b += 1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
- TMaybe<TIncrementOnDestroy> m2 = m1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ TMaybe<TIncrementOnDestroy> m2 = m1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
- TMaybe<TIncrementOnDestroy> m3;
- m3 = m1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ TMaybe<TIncrementOnDestroy> m3;
+ m3 = m1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
}
- b += 3;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ b += 3;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
{
- TMaybe<TIncrementOnDestroy> m4 = TIncrementOnDestroy(&a);
- b += 1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
-
- m4 = TIncrementOnDestroy(&a);
- b += 1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
-
- m4.Clear();
- b += 1;
- UNIT_ASSERT_VALUES_EQUAL(a, b);
-
- m4.Clear();
- UNIT_ASSERT_VALUES_EQUAL(a, b);
+ TMaybe<TIncrementOnDestroy> m4 = TIncrementOnDestroy(&a);
+ b += 1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
+
+ m4 = TIncrementOnDestroy(&a);
+ b += 1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
+
+ m4.Clear();
+ b += 1;
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
+
+ m4.Clear();
+ UNIT_ASSERT_VALUES_EQUAL(a, b);
}
}
Y_UNIT_TEST(TestAssignmentClear) {
- TMaybe<int> m5;
- UNIT_ASSERT(!m5.Defined());
- UNIT_ASSERT(m5.Empty());
- UNIT_ASSERT(m5 == TMaybe<int>());
+ TMaybe<int> m5;
+ UNIT_ASSERT(!m5.Defined());
+ UNIT_ASSERT(m5.Empty());
+ UNIT_ASSERT(m5 == TMaybe<int>());
UNIT_ASSERT(m5 == Nothing());
- UNIT_ASSERT(m5 != TMaybe<int>(4));
+ UNIT_ASSERT(m5 != TMaybe<int>(4));
- m5 = 4;
+ m5 = 4;
- UNIT_ASSERT(m5.Defined());
- UNIT_ASSERT(!m5.Empty());
+ UNIT_ASSERT(m5.Defined());
+ UNIT_ASSERT(!m5.Empty());
- UNIT_ASSERT_VALUES_EQUAL(4, m5.GetRef());
- UNIT_ASSERT(m5 == TMaybe<int>(4));
- UNIT_ASSERT(m5 != TMaybe<int>(3));
- UNIT_ASSERT(m5 != TMaybe<int>());
+ UNIT_ASSERT_VALUES_EQUAL(4, m5.GetRef());
+ UNIT_ASSERT(m5 == TMaybe<int>(4));
+ UNIT_ASSERT(m5 != TMaybe<int>(3));
+ UNIT_ASSERT(m5 != TMaybe<int>());
UNIT_ASSERT(m5 != Nothing());
- m5 = TMaybe<int>(5);
- UNIT_ASSERT(m5.Defined());
- UNIT_ASSERT_VALUES_EQUAL(5, m5.GetRef());
- UNIT_ASSERT(m5 == TMaybe<int>(5));
- UNIT_ASSERT(m5 != TMaybe<int>(4));
+ m5 = TMaybe<int>(5);
+ UNIT_ASSERT(m5.Defined());
+ UNIT_ASSERT_VALUES_EQUAL(5, m5.GetRef());
+ UNIT_ASSERT(m5 == TMaybe<int>(5));
+ UNIT_ASSERT(m5 != TMaybe<int>(4));
- m5 = TMaybe<int>();
- UNIT_ASSERT(m5.Empty());
- UNIT_ASSERT(m5 == TMaybe<int>());
+ m5 = TMaybe<int>();
+ UNIT_ASSERT(m5.Empty());
+ UNIT_ASSERT(m5 == TMaybe<int>());
UNIT_ASSERT(m5 == Nothing());
- UNIT_ASSERT(m5 != TMaybe<int>(5));
+ UNIT_ASSERT(m5 != TMaybe<int>(5));
m5 = 4;
m5 = Nothing();
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index ab6ff59879..f5fa047f5c 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -56,7 +56,7 @@ namespace NPrivate {
return ret;
}
-
+
template <class T, size_t P, class... TArgs>
T* SingletonInt(TArgs&&... args) {
static_assert(sizeof(T) < 32000, "use HugeSingleton instead");
@@ -71,22 +71,22 @@ namespace NPrivate {
return ret;
}
- template <class T>
- class TDefault {
- public:
+ template <class T>
+ class TDefault {
+ public:
template <class... TArgs>
inline TDefault(TArgs&&... args)
: T_(std::forward<TArgs>(args)...)
- {
- }
-
+ {
+ }
+
inline const T* Get() const noexcept {
- return &T_;
- }
-
- private:
- T T_;
- };
+ return &T_;
+ }
+
+ private:
+ T T_;
+ };
template <class T>
struct THeapStore {
@@ -130,7 +130,7 @@ T* HugeSingletonWithPriority(TArgs&&... args) {
return SingletonWithPriority<::NPrivate::THeapStore<T>, P>(std::forward<TArgs>(args)...)->D;
}
-template <class T>
-const T& Default() {
+template <class T>
+const T& Default() {
return *(::NPrivate::SingletonInt<typename ::NPrivate::TDefault<T>, TSingletonTraits<T>::Priority>()->Get());
}
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index d67aeac7bb..09a2d0f140 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -236,9 +236,9 @@ char* TTempBuf::Current() noexcept {
}
const char* TTempBuf::Current() const noexcept {
- return Data() + Filled();
-}
-
+ return Data() + Filled();
+}
+
size_t TTempBuf::Filled() const noexcept {
return Impl_->Filled();
}
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index 226c9c0aaa..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -68,7 +68,7 @@ private:
public:
TTempArray() = default;
-
+
TTempArray(size_t len)
: TTempBuf(RawSize(len))
{
@@ -77,11 +77,11 @@ public:
T* Data() noexcept {
return TypedPointer(TTempBuf::Data());
}
-
+
const T* Data() const noexcept {
return TypedPointer(TTempBuf::Data());
}
-
+
T* Current() noexcept {
return TypedPointer(TTempBuf::Current());
}
@@ -89,7 +89,7 @@ public:
const T* Current() const noexcept {
return TypedPointer(TTempBuf::Current());
}
-
+
size_t Size() const noexcept {
return TypedSize(TTempBuf::Size());
}
diff --git a/util/network/address.h b/util/network/address.h
index 47e20fb2a2..448fcac0c9 100644
--- a/util/network/address.h
+++ b/util/network/address.h
@@ -91,7 +91,7 @@ namespace NAddr {
}
private:
- const addrinfo* const AI_;
+ const addrinfo* const AI_;
};
//compat, for TIpAddress
@@ -111,7 +111,7 @@ namespace NAddr {
}
private:
- const TIpAddress A_;
+ const TIpAddress A_;
};
//same, for ipv6 addresses
@@ -131,6 +131,6 @@ namespace NAddr {
}
private:
- const sockaddr_in6 A_;
+ const sockaddr_in6 A_;
};
}
diff --git a/util/network/poller.cpp b/util/network/poller.cpp
index 932d5c4071..7954d0e8b5 100644
--- a/util/network/poller.cpp
+++ b/util/network/poller.cpp
@@ -49,10 +49,10 @@ void TSocketPoller::WaitWrite(SOCKET sock, void* cookie) {
Impl_->Set(cookie, sock, CONT_POLL_WRITE);
}
-void TSocketPoller::WaitReadWrite(SOCKET sock, void* cookie) {
- Impl_->Set(cookie, sock, CONT_POLL_READ | CONT_POLL_WRITE);
-}
-
+void TSocketPoller::WaitReadWrite(SOCKET sock, void* cookie) {
+ Impl_->Set(cookie, sock, CONT_POLL_READ | CONT_POLL_WRITE);
+}
+
void TSocketPoller::WaitRdhup(SOCKET sock, void* cookie) {
Impl_->Set(cookie, sock, CONT_POLL_RDHUP);
}
diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h
index 7bc6900289..e8c7e40fba 100644
--- a/util/network/pollerimpl.h
+++ b/util/network/pollerimpl.h
@@ -160,29 +160,29 @@ public:
}
static inline int ExtractStatus(const TEvent* event) noexcept {
- if (event->flags & EV_ERROR) {
- return EIO;
- }
-
+ if (event->flags & EV_ERROR) {
+ return EIO;
+ }
+
return event->fflags;
}
static inline int ExtractFilterImpl(const TEvent* event) noexcept {
if (event->filter == EVFILT_READ) {
- return CONT_POLL_READ;
- }
+ return CONT_POLL_READ;
+ }
+
+ if (event->filter == EVFILT_WRITE) {
+ return CONT_POLL_WRITE;
+ }
- if (event->filter == EVFILT_WRITE) {
- return CONT_POLL_WRITE;
- }
-
if (event->flags & EV_EOF) {
return CONT_POLL_READ | CONT_POLL_WRITE;
}
- return 0;
- }
-
+ return 0;
+ }
+
private:
int Fd_;
};
@@ -287,23 +287,23 @@ public:
}
static inline int ExtractFilterImpl(const TEvent* event) noexcept {
- int ret = 0;
-
- if (event->events & EPOLLIN) {
- ret |= CONT_POLL_READ;
- }
-
- if (event->events & EPOLLOUT) {
- ret |= CONT_POLL_WRITE;
- }
-
+ int ret = 0;
+
+ if (event->events & EPOLLIN) {
+ ret |= CONT_POLL_READ;
+ }
+
+ if (event->events & EPOLLOUT) {
+ ret |= CONT_POLL_WRITE;
+ }
+
if (event->events & EPOLLRDHUP) {
ret |= CONT_POLL_RDHUP;
}
- return ret;
- }
-
+ return ret;
+ }
+
private:
int Fd_;
};
@@ -585,8 +585,8 @@ public:
static inline int ExtractFilterImpl(const TEvent* event) noexcept {
return event->Filter();
- }
-
+ }
+
private:
inline void Signal() noexcept {
char ch = 13;
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index bd7d2dd867..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -1008,7 +1008,7 @@ public:
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
-
+
hints.ai_flags = flags;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -1071,9 +1071,9 @@ TNetworkAddress::TNetworkAddress(const TUnixSocketPath& unixSocketPath, int flag
TNetworkAddress::TNetworkAddress(const TString& host, ui16 port, int flags)
: Impl_(new TImpl(host.data(), port, flags))
-{
-}
-
+{
+}
+
TNetworkAddress::TNetworkAddress(const TString& host, ui16 port)
: Impl_(new TImpl(host.data(), port, 0))
{
diff --git a/util/str_stl.h b/util/str_stl.h
index cd0321ee1a..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -254,8 +254,8 @@ struct TLess<TUtf32String>: public TLess<TUtf32StringBuf> {
template <class T>
struct TGreater: public std::greater<T> {
-};
-
+};
+
template <>
struct TGreater<TString>: public TGreater<TStringBuf> {
using is_transparent = void;
diff --git a/util/stream/tempbuf.h b/util/stream/tempbuf.h
index caebc3add8..a6dc001025 100644
--- a/util/stream/tempbuf.h
+++ b/util/stream/tempbuf.h
@@ -9,13 +9,13 @@ public:
inline TTempBufOutput() = default;
explicit TTempBufOutput(size_t size)
- : TTempBuf(size)
+ : TTempBuf(size)
{
}
-
+
TTempBufOutput(TTempBufOutput&&) noexcept = default;
TTempBufOutput& operator=(TTempBufOutput&&) noexcept = default;
protected:
void DoWrite(const void* data, size_t len) override;
-};
+};
diff --git a/util/system/guard.h b/util/system/guard.h
index 0bb93f0b88..efc091d5f8 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -21,19 +21,19 @@ struct TTryLockOps: public TCommonLockOps<T> {
};
//must be used with great care
-template <class TOps>
+template <class TOps>
struct TInverseLockOps: public TOps {
- template <class T>
+ template <class T>
static inline void Acquire(T* t) noexcept {
- TOps::Release(t);
- }
-
- template <class T>
+ TOps::Release(t);
+ }
+
+ template <class T>
static inline void Release(T* t) noexcept {
- TOps::Acquire(t);
- }
-};
-
+ TOps::Acquire(t);
+ }
+};
+
template <class T, class TOps = TCommonLockOps<T>>
class TGuard: public TNonCopyable {
public:
diff --git a/util/system/pipe.cpp b/util/system/pipe.cpp
index 1d098e8966..a543bd7472 100644
--- a/util/system/pipe.cpp
+++ b/util/system/pipe.cpp
@@ -98,7 +98,7 @@ public:
return Handle_;
}
- size_t Read(void* buffer, size_t count) const {
+ size_t Read(void* buffer, size_t count) const {
ssize_t r = Handle_.Read(buffer, count);
if (r < 0) {
ythrow TFileError() << "failed to read from pipe";
@@ -106,7 +106,7 @@ public:
return r;
}
- size_t Write(const void* buffer, size_t count) const {
+ size_t Write(const void* buffer, size_t count) const {
ssize_t r = Handle_.Write(buffer, count);
if (r < 0) {
ythrow TFileError() << "failed to write to pipe";
@@ -142,11 +142,11 @@ bool TPipe::IsOpen() const noexcept {
return Impl_->IsOpen();
}
-size_t TPipe::Read(void* buf, size_t len) const {
+size_t TPipe::Read(void* buf, size_t len) const {
return Impl_->Read(buf, len);
}
-size_t TPipe::Write(const void* buf, size_t len) const {
+size_t TPipe::Write(const void* buf, size_t len) const {
return Impl_->Write(buf, len);
}
diff --git a/util/system/pipe.h b/util/system/pipe.h
index c56dd1b4ae..75d0360049 100644
--- a/util/system/pipe.h
+++ b/util/system/pipe.h
@@ -73,8 +73,8 @@ public:
bool IsOpen() const noexcept;
PIPEHANDLE GetHandle() const noexcept;
- size_t Read(void* buf, size_t len) const;
- size_t Write(const void* buf, size_t len) const;
+ size_t Read(void* buf, size_t len) const;
+ size_t Write(const void* buf, size_t len) const;
// Only CloseOnExec is supported
static void Pipe(TPipe& reader, TPipe& writer, EOpenMode mode = 0);
diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp
index a4ac69fad6..bb3dcbf188 100644
--- a/util/system/rwlock.cpp
+++ b/util/system/rwlock.cpp
@@ -171,44 +171,44 @@ TRWMutex::TImpl::TImpl() {
}
TRWMutex::TImpl::~TImpl() {
- const int result = pthread_rwlock_destroy(&Lock_);
+ const int result = pthread_rwlock_destroy(&Lock_);
Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::AcquireRead() noexcept {
- const int result = pthread_rwlock_rdlock(&Lock_);
+ const int result = pthread_rwlock_rdlock(&Lock_);
Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result));
}
bool TRWMutex::TImpl::TryAcquireRead() noexcept {
- const int result = pthread_rwlock_tryrdlock(&Lock_);
+ const int result = pthread_rwlock_tryrdlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
void TRWMutex::TImpl::ReleaseRead() noexcept {
- const int result = pthread_rwlock_unlock(&Lock_);
+ const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::AcquireWrite() noexcept {
- const int result = pthread_rwlock_wrlock(&Lock_);
+ const int result = pthread_rwlock_wrlock(&Lock_);
Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result));
}
bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
- const int result = pthread_rwlock_trywrlock(&Lock_);
+ const int result = pthread_rwlock_trywrlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
void TRWMutex::TImpl::ReleaseWrite() noexcept {
- const int result = pthread_rwlock_unlock(&Lock_);
+ const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::Release() noexcept {
- const int result = pthread_rwlock_unlock(&Lock_);
+ const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result));
}
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 2d32e9ee8f..6236746c2d 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -355,18 +355,18 @@ TThread::TId TThread::CurrentThreadNumericId() noexcept {
TThread::TId TThread::ImpossibleThreadId() noexcept {
return Max<TThread::TId>();
}
-
-namespace {
+
+namespace {
template <class T>
static void* ThreadProcWrapper(void* param) {
return reinterpret_cast<T*>(param)->ThreadProc();
}
-}
-
+}
+
ISimpleThread::ISimpleThread(size_t stackSize)
: TThread(TParams(ThreadProcWrapper<ISimpleThread>, reinterpret_cast<void*>(this), stackSize))
-{
-}
+{
+}
#if defined(_MSC_VER)
// This beautiful piece of code is borrowed from
diff --git a/util/system/thread.h b/util/system/thread.h
index 3040ca59de..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -28,7 +28,7 @@ public:
void* StackPointer;
// See comments for `SetCurrentThreadName`
TString Name = GetProgramName();
-
+
inline TParams()
: Proc(nullptr)
, Data(nullptr)
@@ -36,7 +36,7 @@ public:
, StackPointer(nullptr)
{
}
-
+
inline TParams(TThreadProc proc, void* data)
: Proc(proc)
, Data(data)
@@ -156,15 +156,15 @@ private:
class TImpl;
THolder<TImpl> Impl_;
};
-
+
class ISimpleThread: public TThread {
public:
ISimpleThread(size_t stackSize = 0);
-
+
virtual ~ISimpleThread() = default;
-
+
virtual void* ThreadProc() = 0;
-};
+};
struct TCurrentThreadLimits {
TCurrentThreadLimits() noexcept;