Announcement

Collapse
No announcement yet.

GCC 11 Enables Co-Routines Support In C++20 Mode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • bug77
    replied
    Originally posted by pal666 View Post
    coroutines have nothing to do with threads, they are syntactic sugar for callbacks(single threaded). they don't run concurrently and do not require synchronization, which has impact on reasoning and on execution
    Actually, coroutines do run concurrently, they just don't run in parallel. But I'm just posting this for correctness' sake, I frequently mix those two up myself.

    Leave a comment:


  • kreijack
    replied
    Originally posted by dev_null View Post
    Thanks!. Looks like it won't work on Linux at full power though, and most likely won't work at gcc-10 without some adoption.
    True, I copied an example from the site but I didn't try to run. However my point was to highlight that the differences between the standard (which provides a very low level interface) and the library which will provide a more user (/developer) friendly interface.

    Leave a comment:


  • pal666
    replied
    Originally posted by dev_null View Post
    I personally want to resolve an asynchronous hell.
    networking ts could be merged into c++23

    Leave a comment:


  • pal666
    replied
    Originally posted by Mark625 View Post
    I'm kind of curious about what the motivation is for co-routines, though, since threads are better and fully supported.
    coroutines have nothing to do with threads, they are syntactic sugar for callbacks(single threaded). they don't run concurrently and do not require synchronization, which has impact on reasoning and on execution

    Leave a comment:


  • dev_null
    replied
    Originally posted by pal666 View Post
    it is possible, boost provides one. stackful and stackless both have their pros and cons, it's good to have both(or something combined, and there was an effort to combine them, but it wasn't successful yet)
    microsoft was impatient because they need them for their api
    I personally want to resolve an asynchronous hell. It's when you have a lot of lambdas/callbacks like described here but for C++ https://blog.hellojs.org/asynchronou...t-9b9ceb63c8e8
    So I was extremely disappointed that the new coroutines just don't allow me to do this anyhow easily.

    Leave a comment:


  • dev_null
    replied
    Originally posted by kreijack View Post

    The current implementation is the basic plumbing on which it is possible to build a library support. The intended use is not for the generic developer. You should look to a library like cppcoro https://github.com/lewissbaker/cppcoro which is a lot more user friendly :

    Code:
    using cppcoro;
    generator<const std::uint64_t> fibonacci() {
    std::uint64_t a = 0, b = 1;
    while (true) {
    co_yield b;
    auto tmp = a;
    a = b;
    b += tmp;
    }
    }
    void usage() {
    for (auto i : fibonacci()) {
    if (i > 1'000'000)
    break;
    std::cout << i << std::endl;
    }
    }
    Thanks!. Looks like it won't work on Linux at full power though, and most likely won't work at gcc-10 without some adoption.

    Leave a comment:


  • pal666
    replied
    Originally posted by kreijack View Post
    Code:
    std::cout << i << std::endl;
    http://CppCon.org—Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2017—Lightning Talk—...


    Leave a comment:


  • pal666
    replied
    Originally posted by dev_null View Post
    these new coroutines are extremely hard to use. Everyone who doesn’t believe welcome to try. I have no idea why it was not possible to provide stackfull coroutines python or java script style ??
    it is possible, boost provides one. stackful and stackless both have their pros and cons, it's good to have both(or something combined, and there was an effort to combine them, but it wasn't successful yet)
    Originally posted by dev_null View Post
    However I know the current implementation in the standard was proposed by a guy from Microsoft.
    microsoft was impatient because they need them for their api

    Leave a comment:


  • pal666
    replied
    Originally posted by cl333r View Post
    I think C++ deserves a pat on the back for trying to catch up to Rust
    you live in an alternative universe where rust had coroutines before c++?

    Leave a comment:


  • sindr
    replied
    Originally posted by bug77 View Post
    On the other hand Go's version, goroutines, are spread by the runtime over any number of available threads.
    Yep, see also Erlang and Project Loom's implementations.

    Leave a comment:

Working...
X