Skip to content

Instantly share code, notes, and snippets.

@HappyCerberus
Created November 30, 2021 10:38
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/e822fb0edf6b61609472795fc8231d97 to your computer and use it in GitHub Desktop.
Save HappyCerberus/e822fb0edf6b61609472795fc8231d97 to your computer and use it in GitHub Desktop.
[Article] C++20 Practical Coroutines - scheduler
scheduler_task main_scheduler_impl() {
auto &promise = co_await scheduler_task::get_promise;
while (true) {
for (auto &em : promise.emitters_) {
for (auto *ev = em->emit(); ev != nullptr; ev = em->emit()) {
co_yield ev;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment