source:
tests/exceptions/cancel/coroutine.cfa@
3c1e432
      
      | Last change on this file since 3c1e432 was d3cf623, checked in by , 11 months ago | |
|---|---|
| 
 | |
| File size: 644 bytes | |
| Rev | Line | |
|---|---|---|
| [1c01c58] | 1 | // Try cancelling a coroutine. | 
| 2 | ||
| [3bf9d10] | 3 | #include <fstream.hfa> | 
| [1c01c58] | 4 | #include <coroutine.hfa> | 
| 5 | ||
| [d00d581] | 6 | exception internal_error {}; | 
| 7 | vtable(internal_error) internal_vt; | |
| [1c01c58] | 8 | |
| 9 | coroutine WillCancel {}; | |
| 10 | ||
| [d3cf623] | 11 | const char * msg(CoroutineCancelled(WillCancel) *) { | 
| [1c01c58] | 12 | return "CoroutineCancelled(WillCancel)"; | 
| 13 | } | |
| 14 | ||
| [d3cf623] | 15 | void main(WillCancel &) { | 
| [3bf9d10] | 16 | sout | '1'; | 
| [ecfd758] | 17 | cancel_stack((internal_error){&internal_vt}); | 
| [3bf9d10] | 18 | sout | '!'; | 
| [1c01c58] | 19 | } | 
| 20 | ||
| [d3cf623] | 21 | int main() { | 
| [3bf9d10] | 22 | sout | nlOff; | 
| [1c01c58] | 23 | WillCancel cancel; | 
| 24 | try { | |
| [3bf9d10] | 25 | sout | '0'; | 
| [1c01c58] | 26 | resume(cancel); | 
| [3bf9d10] | 27 | sout | '4'; | 
| [b583113] | 28 | } catchResume (CoroutineCancelled(WillCancel) * error) { | 
| [3bf9d10] | 29 | sout | '2'; | 
| [1c01c58] | 30 | if ((virtual internal_error *)error->the_exception) { | 
| [3bf9d10] | 31 | sout | '3'; | 
| [1c01c58] | 32 | } | 
| 33 | } | |
| [3bf9d10] | 34 | sout | '5' | nl; | 
| [1c01c58] | 35 | } | 
  Note:
 See   TracBrowser
 for help on using the repository browser.
    