diff options
author | Alexey Borzenkov <snaury@yandex-team.ru> | 2022-02-10 16:47:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:41 +0300 |
commit | 22d92781ba2a10b7fb5b977b7d1a5c40ff53885f (patch) | |
tree | 852611fd27f734847435b37aa5b0ad5d8b1c10ac /library/cpp/threading | |
parent | 667a4ee7da2e004784b9c3cfab824a81e96f4d66 (diff) | |
download | ydb-22d92781ba2a10b7fb5b977b7d1a5c40ff53885f.tar.gz |
Restoring authorship annotation for Alexey Borzenkov <snaury@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r-- | library/cpp/threading/future/core/future-inl.h | 8 | ||||
-rw-r--r-- | library/cpp/threading/future/core/future.h | 22 | ||||
-rw-r--r-- | library/cpp/threading/future/future_ut.cpp | 8 | ||||
-rw-r--r-- | library/cpp/threading/skip_list/skiplist_ut.cpp | 204 |
4 files changed, 121 insertions, 121 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index 5fd4296a93..506c77d4c8 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -619,8 +619,8 @@ namespace NThreading { template <typename T> template <typename F> - inline TFuture<TFutureType<TFutureCallResult<F, T>>> TFuture<T>::Apply(F&& func) const { - auto promise = NewPromise<TFutureType<TFutureCallResult<F, T>>>(); + inline TFuture<TFutureType<TFutureCallResult<F, T>>> TFuture<T>::Apply(F&& func) const { + auto promise = NewPromise<TFutureType<TFutureCallResult<F, T>>>(); Subscribe([promise, func = std::forward<F>(func)](const TFuture<T>& future) mutable { NImpl::SetValue(promise, [&]() { return func(future); }); }); @@ -718,8 +718,8 @@ namespace NThreading { template <typename F> - inline TFuture<TFutureType<TFutureCallResult<F, void>>> TFuture<void>::Apply(F&& func) const { - auto promise = NewPromise<TFutureType<TFutureCallResult<F, void>>>(); + inline TFuture<TFutureType<TFutureCallResult<F, void>>> TFuture<void>::Apply(F&& func) const { + auto promise = NewPromise<TFutureType<TFutureCallResult<F, void>>>(); Subscribe([promise, func = std::forward<F>(func)](const TFuture<void>& future) mutable { NImpl::SetValue(promise, [&]() { return func(future); }); }); diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index 2e82bb953e..00dc245d9a 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -47,20 +47,20 @@ namespace NThreading { struct TFutureType<TFuture<T>> { using TType = typename TFutureType<T>::TType; }; - - template <typename F, typename T> - struct TFutureCallResult { - // NOTE: separate class for msvc compatibility - using TType = decltype(std::declval<F&>()(std::declval<const TFuture<T>&>())); - }; + + template <typename F, typename T> + struct TFutureCallResult { + // NOTE: separate class for msvc compatibility + using TType = decltype(std::declval<F&>()(std::declval<const TFuture<T>&>())); + }; } template <typename F> using TFutureType = typename NImpl::TFutureType<F>::TType; - template <typename F, typename T> - using TFutureCallResult = typename NImpl::TFutureCallResult<F, T>::TType; - + template <typename F, typename T> + using TFutureCallResult = typename NImpl::TFutureCallResult<F, T>::TType; + //! Type of the future/promise state identifier class TFutureStateId; @@ -109,7 +109,7 @@ namespace NThreading { const TFuture<T>& NoexceptSubscribe(F&& callback) const noexcept; template <typename F> - TFuture<TFutureType<TFutureCallResult<F, T>>> Apply(F&& func) const; + TFuture<TFutureType<TFutureCallResult<F, T>>> Apply(F&& func) const; TFuture<void> IgnoreResult() const; @@ -164,7 +164,7 @@ namespace NThreading { const TFuture<void>& NoexceptSubscribe(F&& callback) const noexcept; template <typename F> - TFuture<TFutureType<TFutureCallResult<F, void>>> Apply(F&& func) const; + TFuture<TFutureType<TFutureCallResult<F, void>>> Apply(F&& func) const; template <typename R> TFuture<R> Return(const R& value) const; diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 05950a568d..377154e867 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -168,7 +168,7 @@ namespace { TTestCallback callback(123); TFuture<int> future = promise.GetFuture() - .Apply([&](const auto& theFuture) { return callback.Func(theFuture); }); + .Apply([&](const auto& theFuture) { return callback.Func(theFuture); }); promise.SetValue(456); UNIT_ASSERT_EQUAL(future.GetValue(), 123 + 456); @@ -180,7 +180,7 @@ namespace { TTestCallback callback(123); TFuture<void> future = promise.GetFuture() - .Apply([&](const auto& theFuture) { return callback.VoidFunc(theFuture); }); + .Apply([&](const auto& theFuture) { return callback.VoidFunc(theFuture); }); promise.SetValue(456); UNIT_ASSERT(future.HasValue()); @@ -191,7 +191,7 @@ namespace { TTestCallback callback(123); TFuture<int> future = promise.GetFuture() - .Apply([&](const auto& theFuture) { return callback.FutureFunc(theFuture); }); + .Apply([&](const auto& theFuture) { return callback.FutureFunc(theFuture); }); promise.SetValue(456); UNIT_ASSERT_EQUAL(future.GetValue(), 123 + 456); @@ -203,7 +203,7 @@ namespace { TTestCallback callback(123); TFuture<void> future = promise.GetFuture() - .Apply([&](const auto& theFuture) { return callback.FutureVoidFunc(theFuture); }); + .Apply([&](const auto& theFuture) { return callback.FutureVoidFunc(theFuture); }); promise.SetValue(456); UNIT_ASSERT(!future.HasValue()); diff --git a/library/cpp/threading/skip_list/skiplist_ut.cpp b/library/cpp/threading/skip_list/skiplist_ut.cpp index 52fcffda66..f1f075c04c 100644 --- a/library/cpp/threading/skip_list/skiplist_ut.cpp +++ b/library/cpp/threading/skip_list/skiplist_ut.cpp @@ -38,148 +38,148 @@ namespace NThreading { Y_UNIT_TEST_SUITE(TSkipListTest) { Y_UNIT_TEST(ShouldBeEmptyAfterCreation) { TMemoryPool pool(1024); - TSkipList<int> list(pool); + TSkipList<int> list(pool); - UNIT_ASSERT_EQUAL(list.GetSize(), 0); - } + UNIT_ASSERT_EQUAL(list.GetSize(), 0); + } Y_UNIT_TEST(ShouldAllowInsertion) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); + } Y_UNIT_TEST(ShouldNotAllowDuplicates) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); - UNIT_ASSERT(!list.Insert(12345678)); - UNIT_ASSERT_EQUAL(list.GetSize(), 1); - } + UNIT_ASSERT(!list.Insert(12345678)); + UNIT_ASSERT_EQUAL(list.GetSize(), 1); + } Y_UNIT_TEST(ShouldContainInsertedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT(list.Contains(12345678)); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(list.Contains(12345678)); + } Y_UNIT_TEST(ShouldNotContainNotInsertedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); - UNIT_ASSERT(!list.Contains(87654321)); - } + UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(!list.Contains(87654321)); + } Y_UNIT_TEST(ShouldIterateAllItems) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); - - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(list.Insert(i)); - } - - TSkipList<int>::TIterator it = list.SeekToFirst(); - for (int i = 1; i <= 8; ++i) { - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), i); - it.Next(); - } - UNIT_ASSERT(!it.IsValid()); - } + TMemoryPool pool(1024); + TSkipList<int> list(pool); + + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(list.Insert(i)); + } + + TSkipList<int>::TIterator it = list.SeekToFirst(); + for (int i = 1; i <= 8; ++i) { + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), i); + it.Next(); + } + UNIT_ASSERT(!it.IsValid()); + } Y_UNIT_TEST(ShouldIterateAllItemsInReverseDirection) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); - - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(list.Insert(i)); - } - - TSkipList<int>::TIterator it = list.SeekToLast(); - for (int i = 8; i > 0; --i) { - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), i); - it.Prev(); - } - UNIT_ASSERT(!it.IsValid()); - } + TMemoryPool pool(1024); + TSkipList<int> list(pool); + + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(list.Insert(i)); + } + + TSkipList<int>::TIterator it = list.SeekToLast(); + for (int i = 8; i > 0; --i) { + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), i); + it.Prev(); + } + UNIT_ASSERT(!it.IsValid()); + } Y_UNIT_TEST(ShouldSeekToFirstItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 1; i < 10; ++i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 1; i < 10; ++i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToFirst(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 1); - } + TSkipList<int>::TIterator it = list.SeekToFirst(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 1); + } Y_UNIT_TEST(ShouldSeekToLastItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - for (int i = 1; i < 10; ++i) { - UNIT_ASSERT(list.Insert(i)); - } + for (int i = 1; i < 10; ++i) { + UNIT_ASSERT(list.Insert(i)); + } - TSkipList<int>::TIterator it = list.SeekToLast(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 9); - } + TSkipList<int>::TIterator it = list.SeekToLast(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 9); + } Y_UNIT_TEST(ShouldSeekToExistingItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(12345678)); + UNIT_ASSERT(list.Insert(12345678)); - TSkipList<int>::TIterator it = list.SeekTo(12345678); - UNIT_ASSERT(it.IsValid()); - } + TSkipList<int>::TIterator it = list.SeekTo(12345678); + UNIT_ASSERT(it.IsValid()); + } Y_UNIT_TEST(ShouldSeekAfterMissedItem) { - TMemoryPool pool(1024); - TSkipList<int> list(pool); + TMemoryPool pool(1024); + TSkipList<int> list(pool); - UNIT_ASSERT(list.Insert(100)); - UNIT_ASSERT(list.Insert(300)); + UNIT_ASSERT(list.Insert(100)); + UNIT_ASSERT(list.Insert(300)); - TSkipList<int>::TIterator it = list.SeekTo(200); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 300); + TSkipList<int>::TIterator it = list.SeekTo(200); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 300); - it.Prev(); - UNIT_ASSERT(it.IsValid()); - UNIT_ASSERT_EQUAL(it.GetValue(), 100); - } + it.Prev(); + UNIT_ASSERT(it.IsValid()); + UNIT_ASSERT_EQUAL(it.GetValue(), 100); + } Y_UNIT_TEST(ShouldCallDtorsOfNonPodTypes) { - UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); - UNIT_ASSERT_EQUAL(TTestObject::Count, 0); + UNIT_ASSERT(!TTypeTraits<TTestObject>::IsPod); + UNIT_ASSERT_EQUAL(TTestObject::Count, 0); - { - TMemoryPool pool(1024); - TSkipList<TTestObject> list(pool); + { + TMemoryPool pool(1024); + TSkipList<TTestObject> list(pool); - UNIT_ASSERT(list.Insert(TTestObject(1))); - UNIT_ASSERT(list.Insert(TTestObject(2))); - - UNIT_ASSERT_EQUAL(TTestObject::Count, 2); - } + UNIT_ASSERT(list.Insert(TTestObject(1))); + UNIT_ASSERT(list.Insert(TTestObject(2))); - UNIT_ASSERT_EQUAL(TTestObject::Count, 0); - } + UNIT_ASSERT_EQUAL(TTestObject::Count, 2); + } + + UNIT_ASSERT_EQUAL(TTestObject::Count, 0); + } } } |