Skip to content

Instantly share code, notes, and snippets.

@HappyCerberus
Last active November 30, 2021 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HappyCerberus/725f5330919d1ec19690181d2c2b5c44 to your computer and use it in GitHub Desktop.
Save HappyCerberus/725f5330919d1ec19690181d2c2b5c44 to your computer and use it in GitHub Desktop.
[Article] C++20 Practical Coroutines - symetric transfer
ces::chainable_task async_op(bool flag) {
using namespace ces::utils;
if (flag) {
co_return AwaitResult{
EventType::Error, 1,
"Couldn't find the truth in the eye of the beholder."};
} else {
co_return AwaitResult{EventType::WakeUp, 0, ""};
}
}
ces::synchronous_task demo() {
if (auto ret = co_await async_op(true); !ret) {
std::cerr << "Asynchronous operation failed: " << ret.err_message << "\n";
}
co_return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment