- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/thread.c
r6b0b624 r83a071f9 1 // -*- Mode: CFA -*- 1 2 // 2 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo … … 9 10 // Author : Thierry Delisle 10 11 // Created On : Tue Jan 17 12:27:26 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 21 22:34:46 201713 // Update Count : 112 // Last Modified By : Thierry Delisle 13 // Last Modified On : -- 14 // Update Count : 0 14 15 // 15 16 … … 32 33 // Thread ctors and dtors 33 34 34 void ?{}(thread_desc *this) {35 ( &this->cor){};36 this ->cor.name = "Anonymous Coroutine";37 this ->mon.owner =this;38 this ->mon.recursion = 1;39 this ->next = NULL;35 void ?{}(thread_desc& this) { 36 (this.cor){}; 37 this.cor.name = "Anonymous Coroutine"; 38 this.mon.owner = &this; 39 this.mon.recursion = 1; 40 this.next = NULL; 40 41 41 this ->current_monitors = &this->mon;42 this ->current_monitor_count = 1;42 this.current_monitors = &this.mon; 43 this.current_monitor_count = 1; 43 44 } 44 45 45 void ^?{}(thread_desc *this) {46 ^( &this->cor){};46 void ^?{}(thread_desc& this) { 47 ^(this.cor){}; 47 48 } 48 49 49 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T *); } )50 void ?{}( scoped(T) *this ) {51 ( &this->handle){};52 __thrd_start( &this->handle);50 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } ) 51 void ?{}( scoped(T)& this ) { 52 (this.handle){}; 53 __thrd_start(this.handle); 53 54 } 54 55 55 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T *, P); } )56 void ?{}( scoped(T) *this, P params ) {57 ( &this->handle){ params };58 __thrd_start( &this->handle);56 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } ) 57 void ?{}( scoped(T)& this, P params ) { 58 (this.handle){ params }; 59 __thrd_start(this.handle); 59 60 } 60 61 61 62 forall( dtype T | sized(T) | is_thread(T) ) 62 void ^?{}( scoped(T) *this ) {63 ^( &this->handle){};63 void ^?{}( scoped(T)& this ) { 64 ^(this.handle){}; 64 65 } 65 66 … … 67 68 // Starting and stopping threads 68 69 forall( dtype T | is_thread(T) ) 69 void __thrd_start( T *this ) {70 void __thrd_start( T& this ) { 70 71 coroutine_desc* thrd_c = get_coroutine(this); 71 72 thread_desc* thrd_h = get_thread (this); … … 77 78 create_stack(&thrd_c->stack, thrd_c->stack.size); 78 79 this_coroutine = thrd_c; 79 CtxStart( this, CtxInvokeThread);80 CtxStart(&this, CtxInvokeThread); 80 81 assert( thrd_c->last->stack.context ); 81 82 CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context ); … … 86 87 87 88 void yield( void ) { 88 BlockInternal( this_thread );89 BlockInternal( (thread_desc *)this_thread ); 89 90 } 90 91
Note:
See TracChangeset
for help on using the changeset viewer.