Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Networking TS #1

Open
qis opened this issue Aug 28, 2017 · 1 comment
Open

Support for Networking TS #1

qis opened this issue Aug 28, 2017 · 1 comment

Comments

@qis
Copy link

qis commented Aug 28, 2017

Are there any plans to support std::experimental::net?

https://github.com/chriskohlhoff/networking-ts-impl

@jamboree
Copy link
Owner

No plans yet. Probably after networking-ts becomes the mainstream.

For now, instead of using act, you can use something simpler:

template<class Coro, class... T>
auto cont(Coro& coro, T&... src)
{
    return [&, coro = std::move(coro)](T... dst) mutable
    {
        bool _[] = {true, (src = std::move(dst), true)...};
        coro();
    };
}

And you can use it this way (if you're using CO2):

std::error_code ec;
std::size_t len;
CO2_SUSPEND([&](auto& coro)
{
    sock.async_read_some(buf, cont(coro, ec, len))
});

To work with Coroutine-TS, you can use this

std::error_code ec;
std::size_t len;
co_await suspend([&](auto& coro)
{
    sock.async_read_some(buf, cont(coro, ec, len))
});

It's more verbose than act, but more flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants