Changeset 71b50f36 for src/tests/coroutine
- Timestamp:
- Apr 29, 2018, 11:58:08 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- db98cd5
- Parents:
- b91e8c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/coroutine/fibonacci.c
rb91e8c1 r71b50f36 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fibonacci.c -- 7 // fibonacci.c -- 3-state finite-state machine 8 8 9 // 9 10 // Author : Thierry Delisle 10 11 // Created On : Thu Jun 8 07:29:37 2017 11 12 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 22 22:45:44201813 // Update Count : 1 513 // Last Modified On : Fri Apr 27 08:55:31 2018 14 // Update Count : 19 14 15 // 15 16 … … 19 20 coroutine Fibonacci { int fn; }; // used for communication 20 21 21 void ?{}( Fibonacci & fib ) with( fib ) { fn = 0; } 22 23 // main automatically called on first resume 24 void main( Fibonacci & fib ) with( fib ) { 22 void main( Fibonacci & fib ) with( fib ) { // called on first resume 25 23 int fn1, fn2; // retained between resumes 26 24 fn = 0; fn1 = fn; // 1st case … … 29 27 suspend(); // restart last resume 30 28 for ( ;; ) { 31 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case29 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 32 30 suspend(); // restart last resume 33 31 } // for
Note: See TracChangeset
for help on using the changeset viewer.