- Timestamp:
- May 6, 2019, 10:09:02 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 63364d8
- Parents:
- b9696a8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/coroutineThen.cfa
rb9696a8 rf019069 1 1 #include <fstream.hfa> 2 2 #include <kernel.hfa> 3 #include <monitor.hfa> 4 #include <thread.hfa> 5 #include <time.hfa> 3 6 #include <stdlib.hfa> 4 #include <thread.hfa> 5 #include <monitor.hfa> 6 #include <time.hfa> 7 #include <string.h> 7 8 8 9 #define __kick_rate 150000ul … … 23 24 #endif 24 25 25 monitor Printer {};26 26 #if !defined(TEST_FOREVER) 27 static inline void print(Printer & mutex this, const char * const text ) { 28 sout | text; 29 } 30 31 static inline void print(Printer & mutex this, const char * const text, int i ) { 32 sout | text | i; 27 static inline void print(const char * const text ) { 28 write( STDERR_FILENO, text, strlen(text) ); 33 29 } 34 30 #else 35 31 static inline void print(Printer & this, const char * const text ) {} 36 static inline void print(Printer & this, const char * const text, int i ) {}37 32 #endif 38 Printer printer;39 33 40 34 coroutine Coroutine {}; … … 58 52 for(int i = 0; TEST(i < N); i++) { 59 53 60 print( printer, "Coroutine 1", i);54 print("C - Suspending"); 61 55 void publish() { 56 print("C - Publishing"); 62 57 assert(!the_cor); 63 58 store( this ); … … 65 60 suspend_then(publish); 66 61 assert(!the_cor); 67 print( printer,"Coroutine 2");62 print("Coroutine 2"); 68 63 KICK_WATCHDOG; 69 64 yield(); … … 82 77 if(!mine) continue; 83 78 84 print( printer, "Thread 1");79 print("T - took"); 85 80 resume(*mine); 86 print( printer, "Thread 2");81 print("T - back"); 87 82 } 88 83 }
Note: See TracChangeset
for help on using the changeset viewer.