diff options
author | ishfb <ishfb@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 069c69f58fd78de3cf2e6eb2304047281e21fb65 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/threading/future/async_ut.cpp | |
parent | 0170772a2dbf133f32e17ca137ff64790d43831f (diff) | |
download | ydb-069c69f58fd78de3cf2e6eb2304047281e21fb65.tar.gz |
Restoring authorship annotation for <ishfb@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/future/async_ut.cpp')
-rw-r--r-- | library/cpp/threading/future/async_ut.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp index c2801dbd6e..a3699744e4 100644 --- a/library/cpp/threading/future/async_ut.cpp +++ b/library/cpp/threading/future/async_ut.cpp @@ -1,32 +1,32 @@ -#include "async.h" - +#include "async.h" + #include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/ptr.h> -#include <util/generic/vector.h> - -namespace { + +#include <util/generic/ptr.h> +#include <util/generic/vector.h> + +namespace { struct TMySuperTaskQueue { }; - -} - -namespace NThreading { + +} + +namespace NThreading { /* Here we provide an Async overload for TMySuperTaskQueue indide NThreading namespace - * so that we can call it in the way - * - * TMySuperTaskQueue queue; - * NThreading::Async([](){}, queue); - * - * See also ExtensionExample unittest. - */ + * so that we can call it in the way + * + * TMySuperTaskQueue queue; + * NThreading::Async([](){}, queue); + * + * See also ExtensionExample unittest. + */ template <typename Func> TFuture<TFunctionResult<Func>> Async(Func func, TMySuperTaskQueue&) { return MakeFuture(func()); } - -} - + +} + Y_UNIT_TEST_SUITE(Async) { Y_UNIT_TEST(ExtensionExample) { TMySuperTaskQueue queue; @@ -34,24 +34,24 @@ Y_UNIT_TEST_SUITE(Async) { future.Wait(); UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - + Y_UNIT_TEST(WorksWithIMtpQueue) { auto queue = MakeHolder<TThreadPool>(); queue->Start(1); - + auto future = NThreading::Async([]() { return 5; }, *queue); future.Wait(); UNIT_ASSERT_VALUES_EQUAL(future.GetValue(), 5); } - + Y_UNIT_TEST(ProperlyDeducesFutureType) { // Compileability test auto queue = CreateThreadPool(1); - + NThreading::TFuture<void> f1 = NThreading::Async([]() {}, *queue); NThreading::TFuture<int> f2 = NThreading::Async([]() { return 5; }, *queue); NThreading::TFuture<double> f3 = NThreading::Async([]() { return 5.0; }, *queue); NThreading::TFuture<TVector<int>> f4 = NThreading::Async([]() { return TVector<int>(); }, *queue); NThreading::TFuture<int> f5 = NThreading::Async([]() { return NThreading::MakeFuture(5); }, *queue); } -} +} |