News for hackers. Stuff that matters.
Re:Show HN: Coros – A Modern C++ Library for Task Parallelism by gsliepen on Wednesday September 25, 2024 @02:24PM (#41650361)
It would be nice if there was a function to wait for tasks and to return the results at the same time, so that you could write something like:

    auto [a, b] = co_await coros::wait_tasks(fib(n - 1), fib(n - 2));
    return a + b;
Re:Show HN: Coros – A Modern C++ Library for Task Parallelism by singledigits on Wednesday September 25, 2024 @03:02PM (#41650791)
Thank you for your feedback.

I understand that working with tasks and retrieving values can feel a bit clunky. The main reason I've structured it this way is that individual tasks are RAII objects, and their coroutine state is destroyed once they go out of scope. However, I could modify the awaitable returned from wait_tasks to store tasks, and then return values directly to the user. This could definitely be a more ergonomic overload for the function. I'll look into it!

Re:Show HN: Coros – A Modern C++ Library for Task Parallelism by fooker on Wednesday September 25, 2024 @03:41PM (#41651087)
If you need this interface, use threads.