- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/coroutine/suspend_then.cfa
rdfa4360 r5b11c25 15 15 16 16 #include <fstream.hfa> 17 #include <coroutine.hfa> 17 18 18 generator Fibonacci { 19 int fn; // used for communication 20 int fn1, fn2; // retained between resumes 21 }; 19 void then() { 20 sout | "Then!"; 21 } 22 23 coroutine Fibonacci { int fn; }; // used for communication 22 24 23 25 void main( Fibonacci & fib ) with( fib ) { // called on first resume 26 int fn1, fn2; // retained between resumes 24 27 fn = 0; fn1 = fn; // 1st case 25 suspend { sout | "Then!"; }// restart last resume28 suspend_then(then); // restart last resume 26 29 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 27 suspend { sout | "Then!"; }// restart last resume30 suspend_then(then); // restart last resume 28 31 for () { 29 32 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 30 suspend { sout | "Then!"; }// restart last resume33 suspend_then(then); // restart last resume 31 34 } // for 32 35 }
Note: See TracChangeset
for help on using the changeset viewer.