From 016a3331095d0eead1ed92141b455a940ab4b593 Mon Sep 17 00:00:00 2001 From: Martin Chang Date: Fri, 2 Feb 2024 22:44:27 +0800 Subject: [PATCH] add docs --- lib/inc/drogon/utils/coroutine.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/inc/drogon/utils/coroutine.h b/lib/inc/drogon/utils/coroutine.h index 272c45e5..36580557 100644 --- a/lib/inc/drogon/utils/coroutine.h +++ b/lib/inc/drogon/utils/coroutine.h @@ -848,8 +848,14 @@ inline internal::EventLoopAwaiter queueInLoopCoro(trantor::EventLoop *loop, /** * @brief Waits for all tasks to complete. Throws exception if any of the tasks * throws. In such cases, all tasks are still waited for completion. + * @param tasks A list of tasks to wait for + * @param loop The event loop to switch to after all tasks are completed + * (default nullptr, which means to keep on whichever thread the last task is + * completed) + * @return A task that completes when all tasks are completed */ -inline Task<> when_all(std::vector> tasks, trantor::EventLoop* loop = nullptr) +inline Task<> when_all(std::vector> tasks, + trantor::EventLoop *loop = nullptr) { std::exception_ptr eptr; std::atomic_size_t counter = tasks.size(); @@ -877,7 +883,7 @@ inline Task<> when_all(std::vector> tasks, trantor::EventLoop* loop = nul }(eptr, counter, waiter, std::move(task)); } co_await waiter; - if(loop) + if (loop) co_await switchThreadCoro(loop); if (eptr)