summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorarkady-e1ppa <[email protected]>2024-04-28 02:09:44 +0300
committerarkady-e1ppa <[email protected]>2024-04-28 02:18:13 +0300
commit2c75f008ecfca5cfe830f799d7fa3f48a9760ce1 (patch)
treed4ecd256b46a250a94bd14ed23bda546de110107 /util
parente476b37cb796475328cc77d0a217d688e072d27c (diff)
YT-21402: Adjust util's IntrusiveList to support more convenient use in lockfree algorithms (and farewell SimpleIntrusiveList)
Should be done 8a7cafa1f535df785680b70b488a2e4fbb46b1b0
Diffstat (limited to 'util')
-rw-r--r--util/generic/intrlist.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index b5d3f2051b5..2982e3a2815 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -39,7 +39,7 @@ public:
Prev_->SetNext(Next_);
Next_->SetPrev(Prev_);
- SetEnd();
+ ResetItem();
}
inline void LinkBefore(TListItem* before) noexcept {
@@ -87,11 +87,6 @@ public:
}
public:
- inline void SetEnd() noexcept {
- Prev_ = this;
- Next_ = Prev_;
- }
-
inline void SetNext(TListItem* item) noexcept {
Next_ = item;
}
@@ -109,6 +104,28 @@ public:
return static_cast<const T*>(this);
}
+public:
+ // NB(arkady-e1ppa): These methods are used to implement
+ // intrusive lock-free algorithms which want to natively
+ // interact with TIntrusiveList.
+ // Assume that if you've used MutableNext/MutablePrev
+ // methods, you are not safe to use anything but
+ // MutableNext/MutablePrev/ResetItem methods until
+ // you call a ResetItem method.
+
+ inline TListItem*& MutableNext() noexcept {
+ return Next_;
+ }
+
+ inline TListItem*& MutablePrev() noexcept {
+ return Prev_;
+ }
+
+ inline void ResetItem() noexcept {
+ Next_ = this;
+ Prev_ = Next_;
+ }
+
private:
inline TIntrusiveListItem(const TIntrusiveListItem&) = delete;
inline TIntrusiveListItem& operator=(const TIntrusiveListItem&) = delete;
@@ -508,6 +525,10 @@ public:
Cut(list.Begin(), list.End(), End());
}
+ inline void Append(TIntrusiveList&& list) noexcept {
+ Append(list);
+ }
+
inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
if (begin == end) {
return;