Skip to content

Instantly share code, notes, and snippets.

@heejune
Created February 19, 2017 17:05
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 heejune/dcd4c15ad93e48d2a45745052e34c05f to your computer and use it in GitHub Desktop.
Save heejune/dcd4c15ad93e48d2a45745052e34c05f to your computer and use it in GitHub Desktop.
resumable test #1
// resumable-idea.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
using namespace std;
struct resumable_thing
{
void resume() {}
};
resumable_thing counter() {
cout << "counter: called\n";
for (unsigned i = 1; ; i++)
{
co_await std::experimental::suspend_always{};
cout << "counter:: resumed\n";
}
}
void main()
{
cout << "main: calling counter\n";
resumable_thing the_counter = counter();
cout << "main: resuming counter\n";
the_counter.resume();
the_counter.resume();
cout << "main: done\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment