Last active
November 30, 2021 09:26
-
-
Save HappyCerberus/725f5330919d1ec19690181d2c2b5c44 to your computer and use it in GitHub Desktop.
[Article] C++20 Practical Coroutines - symetric transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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