diff --git a/lib/inc/drogon/utils/coroutine.h b/lib/inc/drogon/utils/coroutine.h index 1468eabf..484dc12f 100644 --- a/lib/inc/drogon/utils/coroutine.h +++ b/lib/inc/drogon/utils/coroutine.h @@ -928,7 +928,6 @@ inline Task<> when_all(std::vector tasks, trantor::EventLoop *loop = nullptr) { static_assert(is_awaitable_v); - static_assert(std::is_same_v, void>); std::exception_ptr eptr; std::atomic_size_t counter = tasks.size(); internal::WaitForNotify waiter; @@ -937,7 +936,7 @@ inline Task<> when_all(std::vector tasks, [](std::exception_ptr &eptr, std::atomic_size_t &counter, internal::WaitForNotify &waiter, - Task<> task) -> AsyncTask { + Awaiter task) -> AsyncTask { try { co_await task; diff --git a/lib/tests/unittests/CoroutineTest.cc b/lib/tests/unittests/CoroutineTest.cc index 6e20870f..1d75bb4f 100644 --- a/lib/tests/unittests/CoroutineTest.cc +++ b/lib/tests/unittests/CoroutineTest.cc @@ -281,4 +281,12 @@ DROGON_TEST(WhenAll) CHECK(results.size() == 2); CHECK(results[0] == 42); CHECK(results[1] == 42); + + // Check waiting on non-task works + auto sleep = sleepCoro(drogon::app().getLoop(), 0.001); + auto sleep2 = sleepCoro(drogon::app().getLoop(), 0.001); + std::vector tasks5; + tasks5.emplace_back(std::move(sleep)); + tasks5.emplace_back(std::move(sleep2)); + sync_wait(when_all(std::move(tasks5))); }