https://github.com/facebook/folly/tree/main/folly/experiment...
I tried getting into C++ coroutines in the past and I was put off because of the complexity and the lack of an I/O system that was understandable by a human being.
auto [a, b] = co_await coros::wait_tasks(fib(n - 1), fib(n - 2));
return a + b;
Can anyone recommend a good tutorial or resource for me to read.
I find it so frustrating as I don't think it's necessarily a complex subject but my brain just doesn't get it.
Related perhaps but many (many, many) years ago, when learning BASIC, I assumed GOSUB went off and started executing the code in the subroutine as well as the rest of the inline code. That suggests to me that I should perhaps have a deeper understanding of this but I really don't...
[1] https://learn.microsoft.com/en-us/uwp/cpp-ref-for-winrt/resu...
The code seems to rely on atomics for head & tail, but grows the queue without any special provisions I can see.
https://github.com/mtmucha/coros/blob/ee30d3c1d0602c3071aa26...
One thing I'd like to see is the possibility to run the coroutines in the main thread, without spawning any new threads in the thread pool. It might seem strange but sometimes you just need to do I/O stuff concurrently in a place where you're not allowed to spawn other threads.
Other than that congrats on the release, I hope you keep working on it!
FYI: I guess there is a minor typo in the README example: the argument of the second call to fib() in the non-coros version of the code should be "n-2" and not "n-1".
If it works anywhere near as good, I'm definitely giving this a try next time I need to work on a C++ project. Thanks!
At this point in the life-cycle of the concept of parallel computation, I think it has become somewhat imperative that devs in the area begin to honestly evaluate the practicality and benefits/drawbacks of using the techniques for a given application area and attempt to 'sell' their libraries, techniques, idioms, etc using a more transparent approach. Also, I generally think that people that argue for more prevalence of parallel code, especially those arguing for the default being parallel (or concurrent), have to wrestle with and address these same issues.
Again, I don't dislike the premise of the library, think the usage examples seem very sensible and well designed, and I really like parallel computation as an area of study in general. Further, I really think that setting out a task for one's self
'to try building a library using modern features from the C++ standard library. I’ve used coroutines for task encapsulation and C++23 expected for exception handling, while trying to maintain good performance.'
after taking inspiration from two well respected and frequently utilized libraries in the space is great and the internals of the library I saw look clean and well architected.
1 - https://www.usenix.org/system/files/conference/hotos15/hotos... 2 - https://youtu.be/ztY1YRiaSiE?si=npBREw9vdF5dHcJh&t=350