4 ms·
My understanding is C++ coroutines are implemented as threads, which seems to take away the point of coroutines.
by andrewstuart 4y ago
My understanding is C++ coroutines are implemented as threads, which seems to take away the point of coroutines.
- MathMonkeyMan 4y agoI haven't read much about them, but it looks like they can be driven by any event-loopy thing. It's not like creating a coroutine creates a thread. https://en.cppreference.com/w/cpp/language/coroutines https://en.cppreference.com/w/cpp/language/coroutines
- jcelerier 4y agowhere did you get this understanding? this is definitely, 100% wrong, C++ coroutines are not backed by threads at all (or by anything really since as of C++20, the language only provides the building blocks for making your own coroutine / generator types and not actual implementations).
- andrewstuart 4y agoI got that understanding here: https://en.cppreference.com/w/cpp/thread/async https://en.cppreference.com/w/cpp/thread/async
- jcelerier 4y agocoroutines (https://en.cppreference.com/w/cpp/language/coroutines https://en.cppreference.com/w/cpp/language/coroutines) are unrelated to std::async
- andrewstuart 4y agoIn other languages they are tightly related to async/await and I made the mistake of assuming they were connected.
- srott 4y agoI think even gccgo used threads as coroutines, not sure if it's still the case