Announcement

Collapse
No announcement yet.

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

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

  • #11
    Originally posted by pipe13 View Post

    IIRC, C# -- pronounced "Chash" (the first "h" is silent) -- was intended to be a better Java than Java..
    Exactly. It has nothing to do with C.

    In fact the C in the name was due to two things:

    1) The obvious marketing tactic by Microsoft to spread uncertainty and cash in on the popularity and benefits of C++
    2) CSharp used to be called "Microsoft Cool" (How gross is that!). So the "C" derives from that name.

    Don't fall for it kids! C++ is a vastly superior tool and will outlive this cheap Java clone.

    C++/clr on the other hand was fairly good. I could work with twits and yet not have to use their twit language

    Comment


    • #12
      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.
      Coroutine and thread are different things; for example the former, doesn't need synchronization primitive. And typically the latter are use to run different codes in parallel.
      However I have to point out that there are some overlap between the different technologies, mostly if the thread is implemented as "cooperative" thread.

      Comment


      • #13
        Afaik, coroutines don't typically run in parallel (i.e. they only multiplex work on one thread). On the other hand Go's version, goroutines, are spread by the runtime over any number of available threads.
        How do these C++ coroutines work? (I've been out of the loop wit C and C++ for quite a while.)

        Comment


        • #14
          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.

          Comment


          • #15
            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++?

            Comment


            • #16
              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

              Comment


              • #17
                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—...


                Comment


                • #18
                  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.

                  Comment


                  • #19
                    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.

                    Comment


                    • #20
                      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

                      Comment

                      Working...
                      X