ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since 77fde9d5 was             afe2939, checked in by Andrew Beach <ajbeach@…>, 5 years ago           | 
        
        
          | 
             
Removed #include <stdio.h> from tests that only use printf. 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            624 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [1c01c58] | 1 | // Try cancelling a coroutine.
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | #include <coroutine.hfa>
 | 
|---|
 | 4 | #include <exception.hfa>
 | 
|---|
 | 5 | 
 | 
|---|
 | 6 | TRIVIAL_EXCEPTION(internal_error);
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | coroutine WillCancel {};
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | const char * msg(CoroutineCancelled(WillCancel) * this) {
 | 
|---|
 | 11 |         return "CoroutineCancelled(WillCancel)";
 | 
|---|
 | 12 | }
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | void main(WillCancel & wc) {
 | 
|---|
 | 15 |         printf("1");
 | 
|---|
 | 16 |         cancel_stack((internal_error){});
 | 
|---|
 | 17 |         printf("!");
 | 
|---|
 | 18 | }
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | int main(int argc, char * argv[]) {
 | 
|---|
 | 21 |         WillCancel cancel;
 | 
|---|
 | 22 |         try {
 | 
|---|
 | 23 |                 printf("0");
 | 
|---|
 | 24 |                 resume(cancel);
 | 
|---|
 | 25 |                 printf("4");
 | 
|---|
 | 26 |         } catchResume (CoroutineCancelled(WillCancel) * error) {
 | 
|---|
 | 27 |                 printf("2");
 | 
|---|
 | 28 |                 if ((virtual internal_error *)error->the_exception) {
 | 
|---|
 | 29 |                         printf("3");
 | 
|---|
 | 30 |                 }
 | 
|---|
 | 31 |         }
 | 
|---|
 | 32 |         printf("5\n");
 | 
|---|
 | 33 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.