aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorvskipin <vskipin@yandex-team.ru>2022-02-10 16:46:00 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:00 +0300
commit4e4b78bd7b67e2533da4dbb9696374a6d6068e32 (patch)
treea7a5543d815c451256ece74081d960b4e1d70ec2 /util
parent5b00ed04a5137a452fa6d3423cb0c9b54ac27408 (diff)
downloadydb-4e4b78bd7b67e2533da4dbb9696374a6d6068e32.tar.gz
Restoring authorship annotation for <vskipin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/datetime/base.h2
-rw-r--r--util/generic/deque.h2
-rw-r--r--util/generic/flags.h4
-rw-r--r--util/generic/flags_ut.cpp12
-rw-r--r--util/generic/hash.h96
-rw-r--r--util/generic/hash_set.h36
-rw-r--r--util/generic/hash_ut.cpp216
-rw-r--r--util/generic/object_counter.h2
-rw-r--r--util/generic/singleton.h2
-rw-r--r--util/system/atomic.h4
-rw-r--r--util/system/atomic_gcc.h44
-rw-r--r--util/system/atomic_ops.h168
-rw-r--r--util/system/atomic_ut.cpp30
-rw-r--r--util/system/atomic_win.h14
-rw-r--r--util/system/sanitizers.cpp2
-rw-r--r--util/system/sanitizers.h94
-rw-r--r--util/system/sem.cpp6
-rw-r--r--util/system/spinlock.h12
-rw-r--r--util/thread/lfstack.h18
-rw-r--r--util/ya.make2
20 files changed, 383 insertions, 383 deletions
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 5e902b8f63..a08766a46d 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -307,7 +307,7 @@ public:
return Hours(d * 24);
}
- /// parses strings like 10s, 15ms, 15.05s, 20us, or just 25 (s). See parser_ut.cpp for details
+ /// parses strings like 10s, 15ms, 15.05s, 20us, or just 25 (s). See parser_ut.cpp for details
static TDuration Parse(const TStringBuf input);
static bool TryParse(const TStringBuf input, TDuration& result);
diff --git a/util/generic/deque.h b/util/generic/deque.h
index 2dabaf3177..b96f0ea2ba 100644
--- a/util/generic/deque.h
+++ b/util/generic/deque.h
@@ -12,7 +12,7 @@ template <class T, class A>
class TDeque: public std::deque<T, TReboundAllocator<A, T>> {
using TBase = std::deque<T, TReboundAllocator<A, T>>;
-public:
+public:
using TBase::TBase;
inline yssize_t ysize() const noexcept {
diff --git a/util/generic/flags.h b/util/generic/flags.h
index a1f5921d42..b47f7d02c0 100644
--- a/util/generic/flags.h
+++ b/util/generic/flags.h
@@ -234,11 +234,11 @@ struct THash<TFlags<Enum>> {
* @param FLAGS Flags type to declare operator for.
*/
#define Y_DECLARE_OPERATORS_FOR_FLAGS(FLAGS) \
- Y_DECLARE_UNUSED \
+ Y_DECLARE_UNUSED \
constexpr inline FLAGS operator|(FLAGS::TEnum l, FLAGS::TEnum r) { \
return FLAGS(l) | r; \
} \
- Y_DECLARE_UNUSED \
+ Y_DECLARE_UNUSED \
constexpr inline FLAGS operator~(FLAGS::TEnum value) { \
return ~FLAGS(value); \
}
diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp
index 5377c6a058..23ab5a99f8 100644
--- a/util/generic/flags_ut.cpp
+++ b/util/generic/flags_ut.cpp
@@ -22,15 +22,15 @@ enum class ETestFlag2 {
Y_DECLARE_FLAGS(ETest2, ETestFlag2)
Y_DECLARE_OPERATORS_FOR_FLAGS(ETest2)
-namespace {
- // won't compile without Y_DECLARE_UNUSED
+namespace {
+ // won't compile without Y_DECLARE_UNUSED
enum class ETestFlag3 { One = 1,
Two = 2,
Three = 3 };
- Y_DECLARE_FLAGS(ETestFlags3, ETestFlag3)
- Y_DECLARE_OPERATORS_FOR_FLAGS(ETestFlags3)
-}
-
+ Y_DECLARE_FLAGS(ETestFlags3, ETestFlag3)
+ Y_DECLARE_OPERATORS_FOR_FLAGS(ETestFlags3)
+}
+
Y_UNIT_TEST_SUITE(TFlagsTest) {
template <class Enum>
void TestEnum() {
diff --git a/util/generic/hash.h b/util/generic/hash.h
index e46db21fa9..0fea17b3a5 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -1561,39 +1561,39 @@ public:
}
public:
- template <class InputIterator>
- void insert(InputIterator f, InputIterator l) {
- rep.insert_unique(f, l);
- }
-
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) {
+ rep.insert_unique(f, l);
+ }
+
std::pair<iterator, bool> insert(const value_type& obj) {
return rep.insert_unique(obj);
}
-
+
template <typename... Args>
std::pair<iterator, bool> emplace(Args&&... args) {
return rep.emplace_unique(std::forward<Args>(args)...);
}
-
- std::pair<iterator, bool> insert_noresize(const value_type& obj) {
- return rep.insert_unique_noresize(obj);
- }
-
+
+ std::pair<iterator, bool> insert_noresize(const value_type& obj) {
+ return rep.insert_unique_noresize(obj);
+ }
+
template <typename... Args>
std::pair<iterator, bool> emplace_noresize(Args&&... args) {
return rep.emplace_unique_noresize(std::forward<Args>(args)...);
}
-
+
template <class TheObj>
iterator insert_direct(const TheObj& obj, const insert_ctx& ins) {
return rep.insert_direct(obj, ins);
}
- template <typename... Args>
- iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
- return rep.emplace_direct(ins, std::forward<Args>(args)...);
- }
-
+ template <typename... Args>
+ iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
+ return rep.emplace_direct(ins, std::forward<Args>(args)...);
+ }
+
template <typename TKey, typename... Args>
std::pair<iterator, bool> try_emplace(TKey&& key, Args&&... args) {
insert_ctx ctx = nullptr;
@@ -1776,7 +1776,7 @@ public:
using iterator = typename ht::iterator;
using const_iterator = typename ht::const_iterator;
- using insert_ctx = typename ht::insert_ctx;
+ using insert_ctx = typename ht::insert_ctx;
hasher hash_function() const {
return rep.hash_function();
@@ -1886,55 +1886,55 @@ public:
}
public:
- template <class InputIterator>
- void insert(InputIterator f, InputIterator l) {
- rep.insert_equal(f, l);
- }
-
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) {
+ rep.insert_equal(f, l);
+ }
+
iterator insert(const value_type& obj) {
return rep.insert_equal(obj);
}
-
- template <typename... Args>
+
+ template <typename... Args>
iterator emplace(Args&&... args) {
return rep.emplace_equal(std::forward<Args>(args)...);
}
-
+
iterator insert_noresize(const value_type& obj) {
return rep.emplace_equal_noresize(obj);
}
- template <typename... Args>
- iterator emplace_noresize(Args&&... args) {
- return rep.emplace_equal_noresize(std::forward<Args>(args)...);
- }
-
- template <class TheObj>
- iterator insert_direct(const TheObj& obj, const insert_ctx& ins) {
- return rep.insert_direct(obj, ins);
- }
-
- template <typename... Args>
- iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
- return rep.emplace_direct(ins, std::forward<Args>(args)...);
- }
-
+ template <typename... Args>
+ iterator emplace_noresize(Args&&... args) {
+ return rep.emplace_equal_noresize(std::forward<Args>(args)...);
+ }
+
+ template <class TheObj>
+ iterator insert_direct(const TheObj& obj, const insert_ctx& ins) {
+ return rep.insert_direct(obj, ins);
+ }
+
+ template <typename... Args>
+ iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
+ return rep.emplace_direct(ins, std::forward<Args>(args)...);
+ }
+
template <class TKey>
- const_iterator find(const TKey& key) const {
+ const_iterator find(const TKey& key) const {
return rep.find(key);
}
template <class TKey>
- iterator find(const TKey& key) {
+ iterator find(const TKey& key) {
return rep.find(key);
}
template <class TheKey>
- iterator find(const TheKey& key, insert_ctx& ins) {
- return rep.find_i(key, ins);
- }
-
- template <class TheKey>
+ iterator find(const TheKey& key, insert_ctx& ins) {
+ return rep.find_i(key, ins);
+ }
+
+ template <class TheKey>
bool contains(const TheKey& key) const {
return rep.find(key) != rep.end();
}
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h
index e8088cf23b..ac1ff92bbb 100644
--- a/util/generic/hash_set.h
+++ b/util/generic/hash_set.h
@@ -147,15 +147,15 @@ public:
}
public:
- void insert(std::initializer_list<value_type> ilist) {
- insert(ilist.begin(), ilist.end());
- }
-
- template <class InputIterator>
- void insert(InputIterator f, InputIterator l) {
- rep.insert_unique(f, l);
- }
-
+ void insert(std::initializer_list<value_type> ilist) {
+ insert(ilist.begin(), ilist.end());
+ }
+
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) {
+ rep.insert_unique(f, l);
+ }
+
std::pair<iterator, bool> insert(const value_type& obj) {
std::pair<mutable_iterator, bool> p = rep.insert_unique(obj);
return std::pair<iterator, bool>(p.first, p.second);
@@ -165,8 +165,8 @@ public:
std::pair<mutable_iterator, bool> p = rep.emplace_unique(std::forward<Args>(args)...);
return std::pair<iterator, bool>(p.first, p.second);
}
-
- iterator insert(const_iterator, const value_type& obj) { // insert_hint
+
+ iterator insert(const_iterator, const value_type& obj) { // insert_hint
std::pair<mutable_iterator, bool> p = rep.insert_unique(obj);
return p.first;
}
@@ -180,25 +180,25 @@ public:
std::pair<mutable_iterator, bool> p = rep.emplace_unique_noresize(std::forward<Args>(args)...);
return std::pair<iterator, bool>(p.first, p.second);
}
-
+
template <class TheObj>
iterator insert_direct(const TheObj& obj, const insert_ctx& ins) {
return rep.insert_direct(obj, ins);
}
- template <typename... Args>
- iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
- return rep.emplace_direct(ins, std::forward<Args>(args)...);
- }
+ template <typename... Args>
+ iterator emplace_direct(const insert_ctx& ins, Args&&... args) {
+ return rep.emplace_direct(ins, std::forward<Args>(args)...);
+ }
template <class TheKey>
- const_iterator find(const TheKey& key) const {
+ const_iterator find(const TheKey& key) const {
return rep.find(key);
}
template <class TheKey>
iterator find(const TheKey& key, insert_ctx& ins) {
return rep.find_i(key, ins);
}
-
+
template <class TheKey>
bool contains(const TheKey& key) const {
return rep.find(key) != rep.end();
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 0551d58770..53396409f3 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -38,16 +38,16 @@ class THashTest: public TTestBase {
UNIT_TEST(TestAllocation);
UNIT_TEST(TestInsertCopy);
UNIT_TEST(TestEmplace);
- UNIT_TEST(TestEmplaceNoresize);
- UNIT_TEST(TestEmplaceDirect);
+ UNIT_TEST(TestEmplaceNoresize);
+ UNIT_TEST(TestEmplaceDirect);
UNIT_TEST(TestTryEmplace);
UNIT_TEST(TestTryEmplaceCopyKey);
- UNIT_TEST(TestHMMapEmplace);
- UNIT_TEST(TestHMMapEmplaceNoresize);
- UNIT_TEST(TestHMMapEmplaceDirect);
+ UNIT_TEST(TestHMMapEmplace);
+ UNIT_TEST(TestHMMapEmplaceNoresize);
+ UNIT_TEST(TestHMMapEmplaceDirect);
UNIT_TEST(TestHSetEmplace);
- UNIT_TEST(TestHSetEmplaceNoresize);
- UNIT_TEST(TestHSetEmplaceDirect);
+ UNIT_TEST(TestHSetEmplaceNoresize);
+ UNIT_TEST(TestHSetEmplaceDirect);
UNIT_TEST(TestNonCopyable);
UNIT_TEST(TestValueInitialization);
UNIT_TEST(TestAssignmentClear);
@@ -89,16 +89,16 @@ protected:
void TestAllocation();
void TestInsertCopy();
void TestEmplace();
- void TestEmplaceNoresize();
- void TestEmplaceDirect();
+ void TestEmplaceNoresize();
+ void TestEmplaceDirect();
void TestTryEmplace();
void TestTryEmplaceCopyKey();
void TestHSetEmplace();
- void TestHSetEmplaceNoresize();
- void TestHSetEmplaceDirect();
- void TestHMMapEmplace();
- void TestHMMapEmplaceNoresize();
- void TestHMMapEmplaceDirect();
+ void TestHSetEmplaceNoresize();
+ void TestHSetEmplaceDirect();
+ void TestHMMapEmplace();
+ void TestHMMapEmplaceNoresize();
+ void TestHMMapEmplaceDirect();
void TestNonCopyable();
void TestValueInitialization();
void TestAssignmentClear();
@@ -632,65 +632,65 @@ void THashTest::TestInsertErase() {
UNIT_ASSERT(values.erase("foo") == 1);
}
}
-
-namespace {
+
+namespace {
struct TItem: public TSimpleRefCount<TItem> {
const TString Key;
const TString Value;
-
+
TItem(const TString& key, const TString& value)
- : Key(key)
- , Value(value)
+ : Key(key)
+ , Value(value)
{
}
- };
-
+ };
+
using TItemPtr = TIntrusivePtr<TItem>;
-
- struct TSelectKey {
+
+ struct TSelectKey {
const TString& operator()(const TItemPtr& item) const {
- return item->Key;
- }
- };
-
+ return item->Key;
+ }
+ };
+
using TItemMapBase = THashTable<
- TItemPtr,
+ TItemPtr,
TString,
THash<TString>,
- TSelectKey,
+ TSelectKey,
TEqualTo<TString>,
std::allocator<TItemPtr>>;
-
- struct TItemMap: public TItemMapBase {
- TItemMap()
+
+ struct TItemMap: public TItemMapBase {
+ TItemMap()
: TItemMapBase(1, THash<TString>(), TEqualTo<TString>())
{
}
-
+
TItem& Add(const TString& key, const TString& value) {
- insert_ctx ins;
- iterator it = find_i(key, ins);
- if (it == end()) {
- it = insert_direct(new TItem(key, value), ins);
- }
- return **it;
- }
- };
-}
-
-void THashTest::TestResizeOnInsertSmartPtrBug() {
- TItemMap map;
- map.Add("key1", "value1");
- map.Add("key2", "value2");
- map.Add("key3", "value3");
- map.Add("key4", "value4");
- map.Add("key5", "value5");
- map.Add("key6", "value6");
- map.Add("key7", "value7");
- TItem& item = map.Add("key8", "value8");
- UNIT_ASSERT_EQUAL(item.Key, "key8");
- UNIT_ASSERT_EQUAL(item.Value, "value8");
+ insert_ctx ins;
+ iterator it = find_i(key, ins);
+ if (it == end()) {
+ it = insert_direct(new TItem(key, value), ins);
+ }
+ return **it;
+ }
+ };
}
+
+void THashTest::TestResizeOnInsertSmartPtrBug() {
+ TItemMap map;
+ map.Add("key1", "value1");
+ map.Add("key2", "value2");
+ map.Add("key3", "value3");
+ map.Add("key4", "value4");
+ map.Add("key5", "value5");
+ map.Add("key6", "value6");
+ map.Add("key7", "value7");
+ TItem& item = map.Add("key8", "value8");
+ UNIT_ASSERT_EQUAL(item.Key, "key8");
+ UNIT_ASSERT_EQUAL(item.Value, "value8");
+}
template <typename T>
static void EmptyAndInsertTest(typename T::value_type v) {
@@ -889,31 +889,31 @@ void THashTest::TestInsertCopy() {
void THashTest::TestEmplace() {
using hash_t = THashMap<int, TNonCopyableInt<0>>;
- hash_t hash;
+ hash_t hash;
hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
auto it = hash.find(1);
UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
}
-void THashTest::TestEmplaceNoresize() {
+void THashTest::TestEmplaceNoresize() {
using hash_t = THashMap<int, TNonCopyableInt<0>>;
- hash_t hash;
- hash.reserve(1);
- hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
-void THashTest::TestEmplaceDirect() {
+ hash_t hash;
+ hash.reserve(1);
+ hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
+void THashTest::TestEmplaceDirect() {
using hash_t = THashMap<int, TNonCopyableInt<0>>;
- hash_t hash;
- hash_t::insert_ctx ins;
- hash.find(1, ins);
- hash.emplace_direct(ins, std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
+ hash_t hash;
+ hash_t::insert_ctx ins;
+ hash.find(1, ins);
+ hash.emplace_direct(ins, std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
void THashTest::TestTryEmplace() {
static unsigned counter = 0u;
@@ -980,59 +980,59 @@ void THashTest::TestTryEmplaceCopyKey() {
}
}
-void THashTest::TestHMMapEmplace() {
+void THashTest::TestHMMapEmplace() {
using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
- hash_t hash;
- hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
-void THashTest::TestHMMapEmplaceNoresize() {
+ hash_t hash;
+ hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
+void THashTest::TestHMMapEmplaceNoresize() {
using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
- hash_t hash;
- hash.reserve(1);
- hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
-void THashTest::TestHMMapEmplaceDirect() {
+ hash_t hash;
+ hash.reserve(1);
+ hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
+void THashTest::TestHMMapEmplaceDirect() {
using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
- hash_t hash;
- hash_t::insert_ctx ins;
- hash.find(1, ins);
- hash.emplace_direct(ins, std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
- auto it = hash.find(1);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
-}
-
+ hash_t hash;
+ hash_t::insert_ctx ins;
+ hash.find(1, ins);
+ hash.emplace_direct(ins, std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
+ auto it = hash.find(1);
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(it->second), 0);
+}
+
void THashTest::TestHSetEmplace() {
using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
- hash_t hash;
+ hash_t hash;
UNIT_ASSERT(!hash.contains(0));
hash.emplace(0);
UNIT_ASSERT(hash.contains(0));
UNIT_ASSERT(!hash.contains(1));
-}
-
-void THashTest::TestHSetEmplaceNoresize() {
+}
+
+void THashTest::TestHSetEmplaceNoresize() {
using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
- hash_t hash;
- hash.reserve(1);
+ hash_t hash;
+ hash.reserve(1);
UNIT_ASSERT(!hash.contains(0));
hash.emplace_noresize(0);
UNIT_ASSERT(hash.contains(0));
UNIT_ASSERT(!hash.contains(1));
}
-void THashTest::TestHSetEmplaceDirect() {
+void THashTest::TestHSetEmplaceDirect() {
using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
- hash_t hash;
+ hash_t hash;
UNIT_ASSERT(!hash.contains(0));
- hash_t::insert_ctx ins;
- hash.find(0, ins);
- hash.emplace_direct(ins, 1);
+ hash_t::insert_ctx ins;
+ hash.find(0, ins);
+ hash.emplace_direct(ins, 1);
UNIT_ASSERT(hash.contains(0));
UNIT_ASSERT(!hash.contains(1));
}
diff --git a/util/generic/object_counter.h b/util/generic/object_counter.h
index 5257afa2e6..fa0575225e 100644
--- a/util/generic/object_counter.h
+++ b/util/generic/object_counter.h
@@ -42,7 +42,7 @@ public:
* \returns Current object count.
*/
static inline long ResetObjectCount() noexcept {
- return AtomicSwap(&Count_, 0);
+ return AtomicSwap(&Count_, 0);
}
private:
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index f5fa047f5c..cf4795ead4 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -54,7 +54,7 @@ namespace NPrivate {
UnlockRecursive(lock);
- return ret;
+ return ret;
}
template <class T, size_t P, class... TArgs>
diff --git a/util/system/atomic.h b/util/system/atomic.h
index 80265babfd..0de0ad3d54 100644
--- a/util/system/atomic.h
+++ b/util/system/atomic.h
@@ -2,8 +2,8 @@
#include "defaults.h"
-using TAtomicBase = intptr_t;
-using TAtomic = volatile TAtomicBase;
+using TAtomicBase = intptr_t;
+using TAtomic = volatile TAtomicBase;
#if defined(__GNUC__)
#include "atomic_gcc.h"
diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h
index ed8dc2bdc5..39d3987fdf 100644
--- a/util/system/atomic_gcc.h
+++ b/util/system/atomic_gcc.h
@@ -5,32 +5,32 @@
: \
: "memory")
-static inline TAtomicBase AtomicGet(const TAtomic& a) {
- TAtomicBase tmp;
+static inline TAtomicBase AtomicGet(const TAtomic& a) {
+ TAtomicBase tmp;
#if defined(_arm64_)
- __asm__ __volatile__(
- "ldar %x[value], %[ptr] \n\t"
- : [value] "=r"(tmp)
- : [ptr] "Q"(a)
- : "memory");
+ __asm__ __volatile__(
+ "ldar %x[value], %[ptr] \n\t"
+ : [value] "=r"(tmp)
+ : [ptr] "Q"(a)
+ : "memory");
#else
- __atomic_load(&a, &tmp, __ATOMIC_ACQUIRE);
+ __atomic_load(&a, &tmp, __ATOMIC_ACQUIRE);
#endif
- return tmp;
-}
-
-static inline void AtomicSet(TAtomic& a, TAtomicBase v) {
+ return tmp;
+}
+
+static inline void AtomicSet(TAtomic& a, TAtomicBase v) {
#if defined(_arm64_)
- __asm__ __volatile__(
- "stlr %x[value], %[ptr] \n\t"
- : [ptr] "=Q"(a)
- : [value] "r"(v)
- : "memory");
-#else
- __atomic_store(&a, &v, __ATOMIC_RELEASE);
-#endif
+ __asm__ __volatile__(
+ "stlr %x[value], %[ptr] \n\t"
+ : [ptr] "=Q"(a)
+ : [value] "r"(v)
+ : "memory");
+#else
+ __atomic_store(&a, &v, __ATOMIC_RELEASE);
+#endif
}
-
+
static inline intptr_t AtomicIncrement(TAtomic& p) {
return __atomic_add_fetch(&p, 1, __ATOMIC_SEQ_CST);
}
@@ -55,7 +55,7 @@ static inline intptr_t AtomicGetAndAdd(TAtomic& p, intptr_t v) {
return __atomic_fetch_add(&p, v, __ATOMIC_SEQ_CST);
}
-static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) {
+static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) {
(void)p; // disable strange 'parameter set but not used' warning on gcc
intptr_t ret;
__atomic_exchange(p, &v, &ret, __ATOMIC_SEQ_CST);
diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h
index 76766b4a0a..46a4a3a4ab 100644
--- a/util/system/atomic_ops.h
+++ b/util/system/atomic_ops.h
@@ -1,20 +1,20 @@
#pragma once
-#include <util/generic/typetraits.h>
-
-template <typename T>
-inline TAtomic* AsAtomicPtr(T volatile* target) {
- return reinterpret_cast<TAtomic*>(target);
-}
-
-template <typename T>
-inline const TAtomic* AsAtomicPtr(T const volatile* target) {
- return reinterpret_cast<const TAtomic*>(target);
-}
-
-// integral types
-
-template <typename T>
+#include <util/generic/typetraits.h>
+
+template <typename T>
+inline TAtomic* AsAtomicPtr(T volatile* target) {
+ return reinterpret_cast<TAtomic*>(target);
+}
+
+template <typename T>
+inline const TAtomic* AsAtomicPtr(T const volatile* target) {
+ return reinterpret_cast<const TAtomic*>(target);
+}
+
+// integral types
+
+template <typename T>
struct TAtomicTraits {
enum {
Castable = std::is_integral<T>::value && sizeof(T) == sizeof(TAtomicBase) && !std::is_const<T>::value,
@@ -25,18 +25,18 @@ template <typename T, typename TT>
using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>;
template <typename T>
-inline TEnableIfCastable<T, T> AtomicGet(T const volatile& target) {
- return static_cast<T>(AtomicGet(*AsAtomicPtr(&target)));
+inline TEnableIfCastable<T, T> AtomicGet(T const volatile& target) {
+ return static_cast<T>(AtomicGet(*AsAtomicPtr(&target)));
}
template <typename T>
-inline TEnableIfCastable<T, void> AtomicSet(T volatile& target, TAtomicBase value) {
- AtomicSet(*AsAtomicPtr(&target), value);
+inline TEnableIfCastable<T, void> AtomicSet(T volatile& target, TAtomicBase value) {
+ AtomicSet(*AsAtomicPtr(&target), value);
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicIncrement(T volatile& target) {
- return static_cast<T>(AtomicIncrement(*AsAtomicPtr(&target)));
+inline TEnableIfCastable<T, T> AtomicIncrement(T volatile& target) {
+ return static_cast<T>(AtomicIncrement(*AsAtomicPtr(&target)));
}
template <typename T>
@@ -45,8 +45,8 @@ inline TEnableIfCastable<T, T> AtomicGetAndIncrement(T volatile& target) {
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicDecrement(T volatile& target) {
- return static_cast<T>(AtomicDecrement(*AsAtomicPtr(&target)));
+inline TEnableIfCastable<T, T> AtomicDecrement(T volatile& target) {
+ return static_cast<T>(AtomicDecrement(*AsAtomicPtr(&target)));
}
template <typename T>
@@ -55,8 +55,8 @@ inline TEnableIfCastable<T, T> AtomicGetAndDecrement(T volatile& target) {
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicAdd(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicAdd(*AsAtomicPtr(&target), value));
+inline TEnableIfCastable<T, T> AtomicAdd(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicAdd(*AsAtomicPtr(&target), value));
}
template <typename T>
@@ -65,8 +65,8 @@ inline TEnableIfCastable<T, T> AtomicGetAndAdd(T volatile& target, TAtomicBase v
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicSub(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicSub(*AsAtomicPtr(&target), value));
+inline TEnableIfCastable<T, T> AtomicSub(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicSub(*AsAtomicPtr(&target), value));
}
template <typename T>
@@ -75,12 +75,12 @@ inline TEnableIfCastable<T, T> AtomicGetAndSub(T volatile& target, TAtomicBase v
}
template <typename T>
-inline TEnableIfCastable<T, T> AtomicSwap(T volatile* target, TAtomicBase exchange) {
- return static_cast<T>(AtomicSwap(AsAtomicPtr(target), exchange));
+inline TEnableIfCastable<T, T> AtomicSwap(T volatile* target, TAtomicBase exchange) {
+ return static_cast<T>(AtomicSwap(AsAtomicPtr(target), exchange));
}
template <typename T>
-inline TEnableIfCastable<T, bool> AtomicCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
+inline TEnableIfCastable<T, bool> AtomicCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
return AtomicCas(AsAtomicPtr(target), exchange, compare);
}
@@ -90,12 +90,12 @@ inline TEnableIfCastable<T, T> AtomicGetAndCas(T volatile* target, TAtomicBase e
}
template <typename T>
-inline TEnableIfCastable<T, bool> AtomicTryLock(T volatile* target) {
+inline TEnableIfCastable<T, bool> AtomicTryLock(T volatile* target) {
return AtomicTryLock(AsAtomicPtr(target));
}
template <typename T>
-inline TEnableIfCastable<T, bool> AtomicTryAndTryLock(T volatile* target) {
+inline TEnableIfCastable<T, bool> AtomicTryAndTryLock(T volatile* target) {
return AtomicTryAndTryLock(AsAtomicPtr(target));
}
@@ -103,85 +103,85 @@ template <typename T>
inline TEnableIfCastable<T, void> AtomicUnlock(T volatile* target) {
AtomicUnlock(AsAtomicPtr(target));
}
-
-template <typename T>
-inline TEnableIfCastable<T, T> AtomicOr(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicOr(*AsAtomicPtr(&target), value));
-}
-
-template <typename T>
-inline TEnableIfCastable<T, T> AtomicAnd(T volatile& target, TAtomicBase value) {
- return static_cast<T>(AtomicAnd(*AsAtomicPtr(&target), value));
-}
-
+
+template <typename T>
+inline TEnableIfCastable<T, T> AtomicOr(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicOr(*AsAtomicPtr(&target), value));
+}
+
+template <typename T>
+inline TEnableIfCastable<T, T> AtomicAnd(T volatile& target, TAtomicBase value) {
+ return static_cast<T>(AtomicAnd(*AsAtomicPtr(&target), value));
+}
+
template <typename T>
inline TEnableIfCastable<T, T> AtomicXor(T volatile& target, TAtomicBase value) {
return static_cast<T>(AtomicXor(*AsAtomicPtr(&target), value));
}
-// pointer types
-
-template <typename T>
-inline T* AtomicGet(T* const volatile& target) {
- return reinterpret_cast<T*>(AtomicGet(*AsAtomicPtr(&target)));
-}
-
-template <typename T>
-inline void AtomicSet(T* volatile& target, T* value) {
- AtomicSet(*AsAtomicPtr(&target), reinterpret_cast<TAtomicBase>(value));
-}
-
+// pointer types
+
+template <typename T>
+inline T* AtomicGet(T* const volatile& target) {
+ return reinterpret_cast<T*>(AtomicGet(*AsAtomicPtr(&target)));
+}
+
+template <typename T>
+inline void AtomicSet(T* volatile& target, T* value) {
+ AtomicSet(*AsAtomicPtr(&target), reinterpret_cast<TAtomicBase>(value));
+}
+
using TNullPtr = decltype(nullptr);
-template <typename T>
+template <typename T>
inline void AtomicSet(T* volatile& target, TNullPtr) {
- AtomicSet(*AsAtomicPtr(&target), 0);
-}
-
-template <typename T>
-inline T* AtomicSwap(T* volatile* target, T* exchange) {
- return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange)));
-}
-
-template <typename T>
+ AtomicSet(*AsAtomicPtr(&target), 0);
+}
+
+template <typename T>
+inline T* AtomicSwap(T* volatile* target, T* exchange) {
+ return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange)));
+}
+
+template <typename T>
inline T* AtomicSwap(T* volatile* target, TNullPtr) {
- return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), 0));
-}
-
-template <typename T>
-inline bool AtomicCas(T* volatile* target, T* exchange, T* compare) {
- return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare));
-}
-
-template <typename T>
+ return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), 0));
+}
+
+template <typename T>
+inline bool AtomicCas(T* volatile* target, T* exchange, T* compare) {
+ return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare));
+}
+
+template <typename T>
inline T* AtomicGetAndCas(T* volatile* target, T* exchange, T* compare) {
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare)));
}
template <typename T>
inline bool AtomicCas(T* volatile* target, T* exchange, TNullPtr) {
- return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0);
-}
-
-template <typename T>
+ return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0);
+}
+
+template <typename T>
inline T* AtomicGetAndCas(T* volatile* target, T* exchange, TNullPtr) {
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0));
}
template <typename T>
inline bool AtomicCas(T* volatile* target, TNullPtr, T* compare) {
- return AtomicCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare));
-}
-
-template <typename T>
+ return AtomicCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare));
+}
+
+template <typename T>
inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, T* compare) {
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare)));
}
template <typename T>
inline bool AtomicCas(T* volatile* target, TNullPtr, TNullPtr) {
- return AtomicCas(AsAtomicPtr(target), 0, 0);
-}
+ return AtomicCas(AsAtomicPtr(target), 0, 0);
+}
template <typename T>
inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, TNullPtr) {
diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp
index 07211ffba7..c53722766a 100644
--- a/util/system/atomic_ut.cpp
+++ b/util/system/atomic_ut.cpp
@@ -145,13 +145,13 @@ private:
inline void TestAtomicSwap() {
TAtomic v = 0;
- UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 3), 0);
- UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 5), 3);
- UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, -7), 5);
- UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, Max<intptr_t>()), -7);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 3), 0);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, 5), 3);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, -7), 5);
+ UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&v, Max<intptr_t>()), -7);
UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>());
}
-
+
inline void TestAtomicOr() {
TAtomic v = 0xf0;
@@ -173,19 +173,19 @@ private:
UNIT_ASSERT_VALUES_EQUAL(AtomicXor(v, 0xff), 0x00);
}
- inline void TestAtomicPtr() {
- int* p;
+ inline void TestAtomicPtr() {
+ int* p;
AtomicSet(p, nullptr);
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(p), 0);
-
- int i;
- AtomicSet(p, &i);
-
- UNIT_ASSERT_VALUES_EQUAL(AtomicGet(p), &i);
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(p), 0);
+
+ int i;
+ AtomicSet(p, &i);
+
+ UNIT_ASSERT_VALUES_EQUAL(AtomicGet(p), &i);
UNIT_ASSERT_VALUES_EQUAL(AtomicSwap(&p, nullptr), &i);
UNIT_ASSERT(AtomicCas(&p, &i, nullptr));
- }
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TAtomicTest<TAtomic>);
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h
index 65c290e6cc..124abbc698 100644
--- a/util/system/atomic_win.h
+++ b/util/system/atomic_win.h
@@ -2,8 +2,8 @@
#include <intrin.h>
-#define USE_GENERIC_SETGET
-
+#define USE_GENERIC_SETGET
+
#if defined(_i386_)
#pragma intrinsic(_InterlockedIncrement)
@@ -36,8 +36,8 @@ static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) {
return _InterlockedExchangeAdd((volatile long*)&a, b);
}
-static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
- return _InterlockedExchange((volatile long*)a, b);
+static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
+ return _InterlockedExchange((volatile long*)a, b);
}
static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
@@ -80,8 +80,8 @@ static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) {
return _InterlockedExchangeAdd64((volatile __int64*)&a, b);
}
-static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
- return _InterlockedExchange64((volatile __int64*)a, b);
+static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
+ return _InterlockedExchange64((volatile __int64*)a, b);
}
static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
@@ -110,5 +110,5 @@ static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) {
static inline void AtomicBarrier() {
TAtomic val = 0;
- AtomicSwap(&val, 0);
+ AtomicSwap(&val, 0);
}
diff --git a/util/system/sanitizers.cpp b/util/system/sanitizers.cpp
index bb799a9e2e..b17e60a094 100644
--- a/util/system/sanitizers.cpp
+++ b/util/system/sanitizers.cpp
@@ -1,4 +1,4 @@
-#include "sanitizers.h"
+#include "sanitizers.h"
#include "thread.h"
#if defined(_asan_enabled_)
diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h
index 965e5c751e..b7d5a72f6f 100644
--- a/util/system/sanitizers.h
+++ b/util/system/sanitizers.h
@@ -1,22 +1,22 @@
#pragma once
-#include "defaults.h"
-
-extern "C" { // sanitizers API
+#include "defaults.h"
+extern "C" { // sanitizers API
+
#if defined(_asan_enabled_)
void __lsan_ignore_object(const void* p);
#endif
-#if defined(_msan_enabled_)
+#if defined(_msan_enabled_)
void __msan_unpoison(const volatile void* a, size_t size);
void __msan_poison(const volatile void* a, size_t size);
void __msan_check_mem_is_initialized(const volatile void* x, size_t size);
#endif
-}; // sanitizers API
-
-namespace NSan {
+}; // sanitizers API
+
+namespace NSan {
class TFiberContext {
public:
TFiberContext() noexcept;
@@ -54,63 +54,63 @@ namespace NSan {
#endif
}
- // Determines if asan present
+ // Determines if asan present
inline constexpr static bool ASanIsOn() noexcept {
-#if defined(_asan_enabled_)
- return true;
-#else
- return false;
+#if defined(_asan_enabled_)
+ return true;
+#else
+ return false;
#endif
- }
+ }
- // Determines if tsan present
+ // Determines if tsan present
inline constexpr static bool TSanIsOn() noexcept {
-#if defined(_tsan_enabled_)
- return true;
-#else
- return false;
+#if defined(_tsan_enabled_)
+ return true;
+#else
+ return false;
#endif
- }
+ }
- // Determines if msan present
+ // Determines if msan present
inline constexpr static bool MSanIsOn() noexcept {
-#if defined(_msan_enabled_)
- return true;
-#else
- return false;
+#if defined(_msan_enabled_)
+ return true;
+#else
+ return false;
#endif
- }
+ }
- // Make memory region fully initialized (without changing its contents).
+ // Make memory region fully initialized (without changing its contents).
inline static void Unpoison(const volatile void* a, size_t size) noexcept {
-#if defined(_msan_enabled_)
- __msan_unpoison(a, size);
-#else
- Y_UNUSED(a);
- Y_UNUSED(size);
-#endif
- }
-
- // Make memory region fully uninitialized (without changing its contents).
- // This is a legacy interface that does not update origin information. Use __msan_allocated_memory() instead.
+#if defined(_msan_enabled_)
+ __msan_unpoison(a, size);
+#else
+ Y_UNUSED(a);
+ Y_UNUSED(size);
+#endif
+ }
+
+ // Make memory region fully uninitialized (without changing its contents).
+ // This is a legacy interface that does not update origin information. Use __msan_allocated_memory() instead.
inline static void Poison(const volatile void* a, size_t size) noexcept {
-#if defined(_msan_enabled_)
- __msan_poison(a, size);
+#if defined(_msan_enabled_)
+ __msan_poison(a, size);
#else
- Y_UNUSED(a);
- Y_UNUSED(size);
+ Y_UNUSED(a);
+ Y_UNUSED(size);
#endif
- }
+ }
- // Checks that memory range is fully initialized, and reports an error if it is not.
+ // Checks that memory range is fully initialized, and reports an error if it is not.
inline static void CheckMemIsInitialized(const volatile void* a, size_t size) noexcept {
-#if defined(_msan_enabled_)
- __msan_check_mem_is_initialized(a, size);
+#if defined(_msan_enabled_)
+ __msan_check_mem_is_initialized(a, size);
#else
- Y_UNUSED(a);
- Y_UNUSED(size);
+ Y_UNUSED(a);
+ Y_UNUSED(size);
#endif
- }
+ }
inline static void MarkAsIntentionallyLeaked(const void* ptr) noexcept {
#if defined(_asan_enabled_)
diff --git a/util/system/sem.cpp b/util/system/sem.cpp
index 4a93b903b5..5ce3b1e529 100644
--- a/util/system/sem.cpp
+++ b/util/system/sem.cpp
@@ -133,8 +133,8 @@ namespace {
#endif
}
- //The UNIX semaphore object does not support a timed "wait", and
- //hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout.
+ //The UNIX semaphore object does not support a timed "wait", and
+ //hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout.
inline void Acquire() noexcept {
#ifdef _win_
Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore");
@@ -154,7 +154,7 @@ namespace {
// zero-second time-out interval
// WAIT_OBJECT_0: current free count > 0
// WAIT_TIMEOUT: current free count == 0
- return ::WaitForSingleObject(Handle, 0) == WAIT_OBJECT_0;
+ return ::WaitForSingleObject(Handle, 0) == WAIT_OBJECT_0;
#else
#ifdef USE_SYSV_SEMAPHORES
struct sembuf ops[] = {{0, -1, SEM_UNDO | IPC_NOWAIT}};
diff --git a/util/system/spinlock.h b/util/system/spinlock.h
index af2630890a..cd8c6f26a3 100644
--- a/util/system/spinlock.h
+++ b/util/system/spinlock.h
@@ -27,13 +27,13 @@ protected:
};
static inline void SpinLockPause() {
-#if defined(__GNUC__)
- #if defined(_i386_) || defined(_x86_64_)
+#if defined(__GNUC__)
+ #if defined(_i386_) || defined(_x86_64_)
__asm __volatile("pause");
- #elif defined(_arm64_)
- __asm __volatile("yield" ::
- : "memory");
- #endif
+ #elif defined(_arm64_)
+ __asm __volatile("yield" ::
+ : "memory");
+ #endif
#endif
}
diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h
index ca3d95f3c3..cfd9e3aef5 100644
--- a/util/thread/lfstack.h
+++ b/util/thread/lfstack.h
@@ -21,12 +21,12 @@ class TLockFreeStack: TNonCopyable {
}
};
- TNode* Head;
- TNode* FreePtr;
+ TNode* Head;
+ TNode* FreePtr;
TAtomic DequeueCount;
void TryToFreeMemory() {
- TNode* current = AtomicGet(FreePtr);
+ TNode* current = AtomicGet(FreePtr);
if (!current)
return;
if (AtomicAdd(DequeueCount, 0) == 1) {
@@ -44,7 +44,7 @@ class TLockFreeStack: TNonCopyable {
}
void EnqueueImpl(TNode* volatile head, TNode* volatile tail) {
for (;;) {
- tail->Next = AtomicGet(Head);
+ tail->Next = AtomicGet(Head);
if (AtomicCas(&Head, head, tail->Next))
break;
}
@@ -97,7 +97,7 @@ public:
}
bool Dequeue(T* res) {
AtomicAdd(DequeueCount, 1);
- for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
+ for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
if (AtomicCas(&Head, AtomicGet(current->Next), current)) {
*res = std::move(current->Value);
// delete current; // ABA problem
@@ -126,7 +126,7 @@ public:
template <typename TCollection>
void DequeueAll(TCollection* res) {
AtomicAdd(DequeueCount, 1);
- for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
+ for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
if (AtomicCas(&Head, (TNode*)nullptr, current)) {
for (TNode* x = current; x;) {
res->push_back(std::move(x->Value));
@@ -157,7 +157,7 @@ public:
AtomicAdd(DequeueCount, -1);
}
bool DequeueSingleConsumer(T* res) {
- for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
+ for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
if (AtomicCas(&Head, current->Next, current)) {
*res = std::move(current->Value);
delete current; // with single consumer thread ABA does not happen
@@ -170,7 +170,7 @@ public:
// elements are returned in order of dequeue (top to bottom; see example in unittest)
template <typename TCollection>
void DequeueAllSingleConsumer(TCollection* res) {
- for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
+ for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
if (AtomicCas(&Head, (TNode*)nullptr, current)) {
for (TNode* x = current; x;) {
res->push_back(std::move(x->Value));
@@ -183,6 +183,6 @@ public:
}
bool IsEmpty() {
AtomicAdd(DequeueCount, 0); // mem barrier
- return AtomicGet(Head) == nullptr; // without lock, so result is approximate
+ return AtomicGet(Head) == nullptr; // without lock, so result is approximate
}
};
diff --git a/util/ya.make b/util/ya.make
index 6ebe7e40cf..520dfba2e6 100644
--- a/util/ya.make
+++ b/util/ya.make
@@ -303,7 +303,7 @@ JOIN_SRCS(
system/protect.cpp
system/rusage.cpp
system/rwlock.cpp
- system/sanitizers.cpp
+ system/sanitizers.cpp
system/sem.cpp
system/shellcommand.cpp
system/shmat.cpp