Changeset bd98b58 for src/examples
- Timestamp:
- Jan 20, 2017, 4:50:15 PM (8 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, resolv-new, with_gc
- Children:
- 207c7e1d
- Parents:
- dcb42b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/examples/thread.c ¶
rdcb42b8 rbd98b58 10 10 }; 11 11 12 DECL_THREAD(MyThread)12 // DECL_THREAD(MyThread) 13 13 14 14 void ?{}( MyThread * this, unsigned id, unsigned count ) { … … 17 17 } 18 18 19 void main(MyThread* this) {20 sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl;21 suspend();19 // void main(MyThread* this) { 20 // sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl; 21 // yield(); 22 22 23 for(int i = 0; i < this->count; i++) {24 sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl;25 suspend();26 }27 }23 // for(int i = 0; i < this->count; i++) { 24 // sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl; 25 // yield(); 26 // } 27 // } 28 28 29 29 int main(int argc, char* argv[]) { 30 30 31 unsigned itterations = 10u;32 if(argc == 2) {33 int val = ato(argv[1]);34 assert(val >= 0);35 itterations = val;36 }31 // unsigned itterations = 10u; 32 // if(argc == 2) { 33 // int val = ato(argv[1]); 34 // assert(val >= 0); 35 // itterations = val; 36 // } 37 37 38 38 sout | "User main begin" | endl; 39 39 40 {41 thread(MyThread) thread1 = { 1u, itterations };42 thread(MyThread) thread2 = { 2u, itterations };43 }40 // { 41 // thread(MyThread) thread1 = { 1u, itterations }; 42 // thread(MyThread) thread2 = { 2u, itterations }; 43 // } 44 44 45 45 sout | "User main end" | endl;
Note: See TracChangeset
for help on using the changeset viewer.