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

added composed. #90

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

added composed. #90

wants to merge 1 commit into from

Conversation

klemens-morgenstern
Copy link
Collaborator

No description provided.

@klemens-morgenstern
Copy link
Collaborator Author

Downgrading to draft. We'll need internal use-cases to make this relevant.

@klemens-morgenstern
Copy link
Collaborator Author

here is what I am now thinking:

extern promise<int> dummy();
composition<error_code, size_t> compost(asio::ip::tcp::socket & sock) // take the executor from the first argument, also works if it's this!
{
   auto [ec, n] = co_await sock.async_read_some(sock, ...); // automatically apply as_tuple, to discourage exceptions being thrown!
   auto [ex, i] = co_await dummy(); // ex-ptr here

   co_return {ec, n}; // complete
}

so let's say we have

extern composition<error_code, mysql::resultset> mysql::query(mysql::connection & conn, string_view query);

// in promise:

auto rs = co_await mysql::query(conn, "select * from cities"); // throws

auto [ec, rr] = co_await cobalt::as_tuple(mysql::query(conn, "select * from cities")); // now you get the ec instead of an ep here

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

Successfully merging this pull request may close these issues.

1 participant