Changeset 6a490b2 for tests/coroutine/suspend_then.cfa
- Timestamp:
- May 11, 2020, 1:53:29 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 504a7dc
- Parents:
- b7d6a36 (diff), a7b486b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/coroutine/suspend_then.cfa
rb7d6a36 r6a490b2 15 15 16 16 #include <fstream.hfa> 17 #include <coroutine.hfa>18 17 19 void then() { 20 sout | "Then!"; 21 } 22 23 coroutine Fibonacci { int fn; }; // used for communication 18 generator Fibonacci { 19 int fn; // used for communication 20 int fn1, fn2; // retained between resumes 21 }; 24 22 25 23 void main( Fibonacci & fib ) with( fib ) { // called on first resume 26 int fn1, fn2; // retained between resumes27 24 fn = 0; fn1 = fn; // 1st case 28 suspend _then(then);// restart last resume25 suspend { sout | "Then!"; } // restart last resume 29 26 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 30 suspend _then(then);// restart last resume27 suspend { sout | "Then!"; } // restart last resume 31 28 for () { 32 29 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 33 suspend _then(then);// restart last resume30 suspend { sout | "Then!"; } // restart last resume 34 31 } // for 35 32 }
Note: See TracChangeset
for help on using the changeset viewer.