- Timestamp:
- Mar 2, 2020, 4:59:27 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- dfa4360
- Parents:
- 37cdd97
- Location:
- tests
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/coroutineThen.cfa
r37cdd97 r427854b 49 49 50 50 void main(Coroutine& this) { 51 suspend ();51 suspend; 52 52 for(int i = 0; TEST(i < N); i++) { 53 53 54 54 print("C - Suspending"); 55 void publish(){55 suspend{ 56 56 print("C - Publishing"); 57 57 assert(!the_cor); 58 58 store( this ); 59 59 } 60 suspend_then(publish);61 60 assert(!the_cor); 62 61 print("Coroutine 2"); … … 65 64 } 66 65 done = true; 67 suspend ();66 suspend; 68 67 } 69 68 -
tests/concurrent/coroutineYield.cfa
r37cdd97 r427854b 33 33 sout | "Coroutine 2"; 34 34 #endif 35 suspend ();35 suspend; 36 36 } 37 37 } -
tests/coroutine/.in/fmtLines.txt
r37cdd97 r427854b 35 35 for ( fmt.b = 0; fmt.b < 4; fmt.b += 1 ) { // blocks of 4 characters 36 36 for ( ;; ) { // for newline characters 37 suspend ();37 suspend; 38 38 if ( fmt.ch != '\n' ) break; // ignore newline 39 39 } // for -
tests/coroutine/cntparens.cfa
r37cdd97 r427854b 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 6 // 7 7 // cntparens.cfa -- match left/right parenthesis 8 // 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Apr 20 11:04:45 2019 … … 12 12 // Last Modified On : Sat Apr 20 11:06:21 2019 13 13 // Update Count : 1 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 26 26 void main( CntParens & cpns ) with( cpns ) { 27 27 for ( ; ch == '('; cnt += 1 ) { // left parenthesis 28 suspend ();28 suspend; 29 29 } 30 30 for ( ; ch == ')' && cnt > 1; cnt -= 1 ) { // right parenthesis 31 suspend ();31 suspend; 32 32 } 33 33 status = ch == ')' ? Match : Error; 34 34 } // main 35 35 36 36 void ?{}( CntParens & cpns ) with( cpns ) { status = Cont; cnt = 0; } 37 37 -
tests/coroutine/devicedriver.cfa
r37cdd97 r427854b 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // devicedriver.cfa -- 8 // 6 // 7 // devicedriver.cfa -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Mar 16 15:30:34 2019 … … 12 12 // Last Modified On : Sat Apr 20 09:07:19 2019 13 13 // Update Count : 90 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 29 29 30 30 void checkCRC( Driver & d, unsigned int sum ) with( d ) { 31 suspend ();31 suspend; 32 32 unsigned short int crc = byte << 8; // sign extension over written 33 suspend ();33 suspend; 34 34 // prevent sign extension for signed char 35 35 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC; … … 41 41 status = CONT; 42 42 unsigned int lnth = 0, sum = 0; 43 while ( byte != STX ) suspend ();43 while ( byte != STX ) suspend; 44 44 emsg: for () { 45 suspend ();45 suspend; 46 46 choose ( byte ) { // process byte 47 47 case STX: 48 status = ESTX; suspend (); continue msg;48 status = ESTX; suspend; continue msg; 49 49 case ETX: 50 50 break emsg; 51 51 case ESC: 52 suspend ();52 suspend; 53 53 } // choose 54 54 if ( lnth >= MaxMsg ) { // buffer full ? 55 status = ELNTH; suspend (); continue msg;55 status = ELNTH; suspend; continue msg; 56 56 } // if 57 57 msg[lnth++] = byte; … … 60 60 msg[lnth] = '\0'; // terminate string 61 61 checkCRC( d, sum ); // refactor CRC check 62 suspend ();62 suspend; 63 63 } // for 64 64 } // main -
tests/coroutine/fibonacci.cfa
r37cdd97 r427854b 22 22 int fn1, fn2; // retained between resumes 23 23 fn = 0; fn1 = fn; // 1st case 24 suspend (); // restart last resume24 suspend; // restart last resume 25 25 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 26 suspend (); // restart last resume26 suspend; // restart last resume 27 27 for () { 28 28 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 29 suspend (); // restart last resume29 suspend; // restart last resume 30 30 } // for 31 31 } -
tests/coroutine/fibonacci_1.cfa
r37cdd97 r427854b 12 12 // Last Modified On : Thu Mar 21 08:10:45 2019 13 13 // Update Count : 25 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 23 23 [fn1, fn] = [0, 1]; // precompute first two states 24 24 for () { 25 suspend (); // restart last resume25 suspend; // restart last resume 26 26 [fn1, fn] = [fn, fn1 + fn]; // general case 27 27 } // for -
tests/coroutine/fmtLines.cfa
r37cdd97 r427854b 27 27 for ( b = 0; b < 4; b += 1 ) { // blocks of 4 characters 28 28 for () { // for newline characters 29 suspend ();29 suspend; 30 30 if ( ch != '\n' ) break; // ignore newline 31 31 } // for -
tests/coroutine/raii.cfa
r37cdd97 r427854b 39 39 Raii raii = { "Coroutine" }; 40 40 sout | "Before Suspend"; 41 suspend ();41 suspend; 42 42 sout | "After Suspend"; 43 43 } -
tests/coroutine/runningTotal.cfa
r37cdd97 r427854b 25 25 void update( RunTotal & rntl, int input ) with( rntl ) { // helper 26 26 total += input; // remember between activations 27 suspend (); // inactivate on stack27 suspend; // inactivate on stack 28 28 } 29 29 -
tests/coroutine/suspend_then.cfa
r37cdd97 r427854b 18 18 19 19 void then() { 20 sout | "Then!"; 20 21 21 } 22 22 … … 26 26 int fn1, fn2; // retained between resumes 27 27 fn = 0; fn1 = fn; // 1st case 28 suspend _then(then);// restart last resume28 suspend { sout | "Then!"; } // restart last resume 29 29 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 30 suspend _then(then);// restart last resume30 suspend { sout | "Then!"; } // restart last resume 31 31 for () { 32 32 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 33 suspend _then(then);// restart last resume33 suspend { sout | "Then!"; } // restart last resume 34 34 } // for 35 35 }
Note: See TracChangeset
for help on using the changeset viewer.