programming-with-cpp20 icon indicating copy to clipboard operation
programming-with-cpp20 copied to clipboard

Coroutine set

Open wiluite opened this issue 1 year ago • 0 comments

Thanks for the coroutine set.

The evolution of samples from the first one(02.10) to the result is awesome and produces the expected results. However, what if one would use it from the perspective to write something more generic:

For example the data for "sending coroutine" could be just:

    std::vector<byte> fakeBytes {
        'H'_B, 'e'_B, 'l'_B, 'l'_B, 'o'_B
    };

and the code in "parsing coroutine" is co-awaiting and just co-yielding (echoing):

    while (true) {
        byte b = co_await byte{};
        std::string frame{};
        frame.push_back(static_cast<char>(b));
        co_yield frame;
    }

And in this sense the modified (02.10) keeps working as expected, but already the next one doesn't (is crashed). Of course, things were done with an eye to a specific version of the protocol, the outcomes in common seem not functionally equivalent. And I thought that the issues could be interesting.

wiluite avatar Dec 22 '22 17:12 wiluite