Changeset dfa4360
- Timestamp:
- Mar 5, 2020, 5:50:29 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:
- 9306559f
- Parents:
- 427854b
- Location:
- tests
- Files:
-
- 7 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/concurrent/suspend_then.cfa ¶
r427854b rdfa4360 1 1 #include <fstream.hfa> 2 2 #include <kernel.hfa> 3 #include <monitor.hfa>4 3 #include <thread.hfa> 5 4 #include <time.hfa> … … 10 9 #include "long_tests.hfa" 11 10 12 #ifndef PREEMPTION_RATE13 #define PREEMPTION_RATE 10`ms14 #endif15 16 11 Duration default_preemption() { 17 return PREEMPTION_RATE;12 return 0; 18 13 } 19 14 … … 26 21 #if !defined(TEST_FOREVER) 27 22 static inline void print(const char * const text ) { 28 write( STD ERR_FILENO, text, strlen(text) );23 write( STDOUT_FILENO, text, strlen(text) ); 29 24 } 30 25 #else … … 32 27 #endif 33 28 34 coroutine Coroutine {};29 generator Coroutine { int i; }; 35 30 36 31 volatile bool done = false; … … 49 44 50 45 void main(Coroutine& this) { 46 this.i = 0; 51 47 suspend; 52 for( int i = 0; TEST(i < N);i++) {48 for(;TEST(this.i < N); this.i++) { 53 49 54 print("C - Suspending ");50 print("C - Suspending\n"); 55 51 suspend{ 56 print("C - Publishing ");52 print("C - Publishing\n"); 57 53 assert(!the_cor); 58 54 store( this ); 59 55 } 60 56 assert(!the_cor); 61 print("C oroutine 2");57 print("C - Back\n"); 62 58 KICK_WATCHDOG; 63 59 yield(); … … 76 72 if(!mine) continue; 77 73 78 print("T - took ");74 print("T - took\n"); 79 75 resume(*mine); 80 print("T - back");81 76 } 82 77 } -
TabularUnified tests/coroutine/suspend_then.cfa ¶
r427854b rdfa4360 15 15 16 16 #include <fstream.hfa> 17 #include <coroutine.hfa>18 17 19 void then() { 20 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 25 suspend { sout | "Then!"; } // restart last resume
Note: See TracChangeset
for help on using the changeset viewer.