Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // Testing Coroutine Exception Throwing
- // using namespace std;
- // _Event E {};
- //
- // _Coroutine C {
- // void main() { _Throw E(); }
- // public:
- // void mem() { resume(); }
- // };
- //
- // int main() {
- // C c;
- // try {
- // c.mem(); // first call fails
- // } catch ( ... ) {
- // cout << "caught!!!" << endl;
- // }
- // }
- // question for peter
- // func {
- // something broke
- // _resume
- // continue running
- // }
- //
- // try {
- // func
- // } catchresume {
- // if i can fix it {
- // cout <<
- // } else {
- // Throw
- // }
- // } catch {
- //
- // }
- // this runs next
- _Coroutine Test {
- // YOU ADD MEMBERS HERE
- char ch;
- void main() {
- for (;;) {
- cout << "hey" << endl;
- _Resume Error() _At resumer();
- cout << "hey2" << endl;
- suspend();
- }
- }
- public:
- _Event Match {}; // last character match // last character invalid
- _Event Error {};
- void next() {
- resume(); // activate
- }
- };
- int main() {
- Test c;
- try {
- c.next();
- } catch ( Test::Error e ) {
- cout << "hey i caught it" << endl;
- }
- // c.next();
- C: {
- cout << "abc" << endl;
- break C;
- cout << "cba" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement