Changeset 242a902
- Timestamp:
- Jul 18, 2017, 4:35:52 PM (6 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:
- f19339e
- Parents:
- 795d450
- Location:
- src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
r795d450 r242a902 56 56 //============================================================================================= 57 57 58 void ?{}( alarm_node_t *this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {59 this ->thrd = thrd;60 this ->alarm = alarm;61 this ->period = period;62 this ->next = 0;63 this ->set = false;64 this ->kernel_alarm = false;58 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) { 59 this.thrd = thrd; 60 this.alarm = alarm; 61 this.period = period; 62 this.next = 0; 63 this.set = false; 64 this.kernel_alarm = false; 65 65 } 66 66 67 void ?{}( alarm_node_t *this, processor * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {68 this ->proc = proc;69 this ->alarm = alarm;70 this ->period = period;71 this ->next = 0;72 this ->set = false;73 this ->kernel_alarm = true;67 void ?{}( alarm_node_t & this, processor * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) { 68 this.proc = proc; 69 this.alarm = alarm; 70 this.period = period; 71 this.next = 0; 72 this.set = false; 73 this.kernel_alarm = true; 74 74 } 75 75 76 void ^?{}( alarm_node_t *this ) {77 if( this ->set ) {78 unregister_self( this );76 void ^?{}( alarm_node_t & this ) { 77 if( this.set ) { 78 unregister_self( &this ); 79 79 } 80 80 } -
src/libcfa/concurrency/alarm.h
r795d450 r242a902 56 56 typedef alarm_node_t ** __alarm_it_t; 57 57 58 void ?{}( alarm_node_t *this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );59 void ?{}( alarm_node_t *this, processor * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );60 void ^?{}( alarm_node_t *this );58 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ); 59 void ?{}( alarm_node_t & this, processor * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ); 60 void ^?{}( alarm_node_t & this ); 61 61 62 62 struct alarm_list_t { … … 65 65 }; 66 66 67 static inline void ?{}( alarm_list_t *this ) {68 this ->head = 0;69 this ->tail = &this->head;67 static inline void ?{}( alarm_list_t & this ) { 68 this.head = 0; 69 this.tail = &this.head; 70 70 } 71 71 -
src/libcfa/concurrency/coroutine
r795d450 r242a902 34 34 //----------------------------------------------------------------------------- 35 35 // Ctors and dtors 36 void ?{}(coStack_t *this);37 void ?{}(coroutine_desc *this);38 void ?{}(coroutine_desc *this, const char * name);39 void ^?{}(coStack_t *this);40 void ^?{}(coroutine_desc *this);36 void ?{}(coStack_t & this); 37 void ?{}(coroutine_desc & this); 38 void ?{}(coroutine_desc & this, const char * name); 39 void ^?{}(coStack_t & this); 40 void ^?{}(coroutine_desc & this); 41 41 42 42 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/coroutine.c
r795d450 r242a902 43 43 //----------------------------------------------------------------------------- 44 44 // Coroutine ctors and dtors 45 void ?{}(coStack_t *this) {46 this ->size = 65000; // size of stack47 this ->storage = NULL; // pointer to stack48 this ->limit = NULL; // stack grows towards stack limit49 this ->base = NULL; // base of stack50 this ->context = NULL; // address of cfa_context_t51 this ->top = NULL; // address of top of storage52 this ->userStack = false;45 void ?{}(coStack_t& this) { 46 this.size = 65000; // size of stack 47 this.storage = NULL; // pointer to stack 48 this.limit = NULL; // stack grows towards stack limit 49 this.base = NULL; // base of stack 50 this.context = NULL; // address of cfa_context_t 51 this.top = NULL; // address of top of storage 52 this.userStack = false; 53 53 } 54 54 55 void ?{}(coStack_t *this, size_t size) {55 void ?{}(coStack_t& this, size_t size) { 56 56 this{}; 57 this ->size = size;57 this.size = size; 58 58 59 create_stack( this, this->size);59 create_stack(&this, this.size); 60 60 } 61 61 62 void ?{}(coroutine_desc *this) {62 void ?{}(coroutine_desc& this) { 63 63 this{ "Anonymous Coroutine" }; 64 64 } 65 65 66 void ?{}(coroutine_desc *this, const char * name) {67 this ->name = name;68 this ->errno_ = 0;69 this ->state = Start;70 this ->starter = NULL;71 this ->last = NULL;66 void ?{}(coroutine_desc& this, const char * name) { 67 this.name = name; 68 this.errno_ = 0; 69 this.state = Start; 70 this.starter = NULL; 71 this.last = NULL; 72 72 } 73 73 74 void ?{}(coroutine_desc *this, size_t size) {74 void ?{}(coroutine_desc& this, size_t size) { 75 75 this{}; 76 ( &this->stack){size};76 (this.stack){size}; 77 77 } 78 78 79 void ^?{}(coStack_t *this) {79 void ^?{}(coStack_t& this) { 80 80 if ( ! this->userStack ) { 81 81 LIB_DEBUG_DO( 82 if ( mprotect( this ->storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {83 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", this, errno, strerror( errno ) );82 if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) { 83 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) ); 84 84 } 85 85 ); 86 free( this ->storage );86 free( this.storage ); 87 87 } 88 88 } 89 89 90 void ^?{}(coroutine_desc *this) {}90 void ^?{}(coroutine_desc& this) {} 91 91 92 92 // Part of the Public API -
src/libcfa/concurrency/invoke.h
r795d450 r242a902 48 48 #ifdef __CFORALL__ 49 49 extern "Cforall" { 50 void ?{}( struct __thread_queue_t *);50 void ?{}( struct __thread_queue_t & ); 51 51 void append( struct __thread_queue_t *, struct thread_desc * ); 52 52 struct thread_desc * pop_head( struct __thread_queue_t * ); 53 53 54 void ?{}( struct __condition_stack_t *);54 void ?{}( struct __condition_stack_t & ); 55 55 void push( struct __condition_stack_t *, struct __condition_criterion_t * ); 56 56 struct __condition_criterion_t * pop( struct __condition_stack_t * ); 57 57 58 void ?{}(spinlock *this);59 void ^?{}(spinlock *this);58 void ?{}(spinlock & this); 59 void ^?{}(spinlock & this); 60 60 } 61 61 #endif -
src/libcfa/concurrency/kernel
r795d450 r242a902 39 39 }; 40 40 41 void ?{}(semaphore *this, int count = 1);42 void ^?{}(semaphore *this);41 void ?{}(semaphore & this, int count = 1); 42 void ^?{}(semaphore & this); 43 43 void P(semaphore * this); 44 44 void V(semaphore * this); … … 52 52 }; 53 53 54 void ?{}(cluster *this);55 void ^?{}(cluster *this);54 void ?{}(cluster & this); 55 void ^?{}(cluster & this); 56 56 57 57 //----------------------------------------------------------------------------- … … 69 69 unsigned short thrd_count; 70 70 }; 71 static inline void ?{}(FinishAction *this) {72 this ->action_code = No_Action;73 this ->thrd = NULL;74 this ->lock = NULL;71 static inline void ?{}(FinishAction & this) { 72 this.action_code = No_Action; 73 this.thrd = NULL; 74 this.lock = NULL; 75 75 } 76 static inline void ^?{}(FinishAction *this) {}76 static inline void ^?{}(FinishAction & this) {} 77 77 78 78 struct processor { … … 94 94 }; 95 95 96 void ?{}(processor *this);97 void ?{}(processor *this, cluster * cltr);98 void ^?{}(processor *this);96 void ?{}(processor & this); 97 void ?{}(processor & this, cluster * cltr); 98 void ^?{}(processor & this); 99 99 100 100 #endif //KERNEL_H -
src/libcfa/concurrency/kernel.c
r795d450 r242a902 75 75 }; 76 76 77 void ?{}( current_stack_info_t *this ) {78 CtxGet( this ->ctx );79 this ->base = this->ctx.FP;80 this ->storage = this->ctx.SP;77 void ?{}( current_stack_info_t & this ) { 78 CtxGet( this.ctx ); 79 this.base = this.ctx.FP; 80 this.storage = this.ctx.SP; 81 81 82 82 rlimit r; 83 83 getrlimit( RLIMIT_STACK, &r); 84 this ->size = r.rlim_cur;85 86 this ->limit = (void *)(((intptr_t)this->base) - this->size);87 this ->context = &mainThreadCtxStorage;88 this ->top = this->base;89 } 90 91 void ?{}( coStack_t *this, current_stack_info_t * info) {92 this ->size = info->size;93 this ->storage = info->storage;94 this ->limit = info->limit;95 this ->base = info->base;96 this ->context = info->context;97 this ->top = info->top;98 this ->userStack = true;99 } 100 101 void ?{}( coroutine_desc *this, current_stack_info_t * info) {102 ( &this->stack){ info };103 this ->name = "Main Thread";104 this ->errno_ = 0;105 this ->state = Start;106 } 107 108 void ?{}( thread_desc *this, current_stack_info_t * info) {109 ( &this->cor){ info };84 this.size = r.rlim_cur; 85 86 this.limit = (void *)(((intptr_t)this.base) - this.size); 87 this.context = &mainThreadCtxStorage; 88 this.top = this.base; 89 } 90 91 void ?{}( coStack_t & this, current_stack_info_t * info) { 92 this.size = info->size; 93 this.storage = info->storage; 94 this.limit = info->limit; 95 this.base = info->base; 96 this.context = info->context; 97 this.top = info->top; 98 this.userStack = true; 99 } 100 101 void ?{}( coroutine_desc & this, current_stack_info_t * info) { 102 (this.stack){ info }; 103 this.name = "Main Thread"; 104 this.errno_ = 0; 105 this.state = Start; 106 } 107 108 void ?{}( thread_desc & this, current_stack_info_t * info) { 109 (this.cor){ info }; 110 110 } 111 111 112 112 //----------------------------------------------------------------------------- 113 113 // Processor coroutine 114 void ?{}(processorCtx_t *this, processor * proc) {115 ( &this->__cor){ "Processor" };116 this ->proc = proc;117 proc->runner = this;118 } 119 120 void ?{}(processorCtx_t *this, processor * proc, current_stack_info_t * info) {121 ( &this->__cor){ info };122 this ->proc = proc;123 proc->runner = this;124 } 125 126 void ?{}(processor *this) {114 void ?{}(processorCtx_t & this, processor * proc) { 115 (this.__cor){ "Processor" }; 116 this.proc = proc; 117 proc->runner = &this; 118 } 119 120 void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) { 121 (this.__cor){ info }; 122 this.proc = proc; 123 proc->runner = &this; 124 } 125 126 void ?{}(processor & this) { 127 127 this{ systemCluster }; 128 128 } 129 129 130 void ?{}(processor *this, cluster * cltr) {131 this ->cltr = cltr;132 ( &this->terminated){ 0 };133 this ->is_terminated = false;134 this ->preemption_alarm = NULL;135 this ->preemption = default_preemption();136 this ->pending_preemption = false;137 138 start( this );139 } 140 141 void ?{}(processor *this, cluster * cltr, processorCtx_t * runner) {142 this ->cltr = cltr;143 ( &this->terminated){ 0 };144 this ->is_terminated = false;145 this ->preemption_alarm = NULL;146 this ->preemption = default_preemption();147 this ->pending_preemption = false;148 this ->kernel_thread = pthread_self();149 150 this ->runner = runner;130 void ?{}(processor & this, cluster * cltr) { 131 this.cltr = cltr; 132 (this.terminated){ 0 }; 133 this.is_terminated = false; 134 this.preemption_alarm = NULL; 135 this.preemption = default_preemption(); 136 this.pending_preemption = false; 137 138 start( &this ); 139 } 140 141 void ?{}(processor & this, cluster * cltr, processorCtx_t * runner) { 142 this.cltr = cltr; 143 (this.terminated){ 0 }; 144 this.is_terminated = false; 145 this.preemption_alarm = NULL; 146 this.preemption = default_preemption(); 147 this.pending_preemption = false; 148 this.kernel_thread = pthread_self(); 149 150 this.runner = runner; 151 151 LIB_DEBUG_PRINT_SAFE("Kernel : constructing system processor context %p\n", runner); 152 runner{this };152 (*runner){ &this }; 153 153 } 154 154 155 155 LIB_DEBUG_DO( bool validate( alarm_list_t * this ); ) 156 156 157 void ?{}(system_proc_t *this, cluster * cltr, processorCtx_t * runner) {158 ( &this->alarms){};159 ( &this->alarm_lock){};160 this ->pending_alarm = false;161 162 ( &this->proc){ cltr, runner };163 164 verify( validate( &this ->alarms ) );165 } 166 167 void ^?{}(processor *this) {168 if( ! this ->is_terminated ) {169 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this);170 this ->is_terminated = true;171 P( &this->terminated );172 pthread_join( this ->kernel_thread, NULL );173 } 174 } 175 176 void ?{}(cluster *this) {177 ( &this->ready_queue ){};178 ( &this->lock ){};179 } 180 181 void ^?{}(cluster *this) {157 void ?{}(system_proc_t & this, cluster * cltr, processorCtx_t * runner) { 158 (this.alarms){}; 159 (this.alarm_lock){}; 160 this.pending_alarm = false; 161 162 (this.proc){ cltr, runner }; 163 164 verify( validate( &this.alarms ) ); 165 } 166 167 void ^?{}(processor & this) { 168 if( ! this.is_terminated ) { 169 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this); 170 this.is_terminated = true; 171 P( this.terminated ); 172 pthread_join( this.kernel_thread, NULL ); 173 } 174 } 175 176 void ?{}(cluster & this) { 177 ( this.ready_queue ){}; 178 ( this.lock ){}; 179 } 180 181 void ^?{}(cluster & this) { 182 182 183 183 } … … 582 582 //----------------------------------------------------------------------------- 583 583 // Locks 584 void ?{}( spinlock *this ) {585 this ->lock = 0;586 } 587 void ^?{}( spinlock *this ) {584 void ?{}( spinlock & this ) { 585 this.lock = 0; 586 } 587 void ^?{}( spinlock & this ) { 588 588 589 589 } … … 619 619 } 620 620 621 void ?{}( semaphore *this, int count = 1 ) {622 ( &this->lock){};623 this ->count = count;624 ( &this->waiting){};625 } 626 void ^?{}(semaphore *this) {}621 void ?{}( semaphore & this, int count = 1 ) { 622 (this.lock){}; 623 this.count = count; 624 (this.waiting){}; 625 } 626 void ^?{}(semaphore & this) {} 627 627 628 628 void P(semaphore * this) { … … 658 658 //----------------------------------------------------------------------------- 659 659 // Queues 660 void ?{}( __thread_queue_t *this ) {661 this ->head = NULL;662 this ->tail = &this->head;660 void ?{}( __thread_queue_t & this ) { 661 this.head = NULL; 662 this.tail = &this.head; 663 663 } 664 664 … … 681 681 } 682 682 683 void ?{}( __condition_stack_t *this ) {684 this ->top = NULL;683 void ?{}( __condition_stack_t & this ) { 684 this.top = NULL; 685 685 } 686 686 -
src/libcfa/concurrency/monitor
r795d450 r242a902 24 24 #include "stdlib" 25 25 26 static inline void ?{}(monitor_desc *this) {27 this ->owner = NULL;28 this ->recursion = 0;26 static inline void ?{}(monitor_desc & this) { 27 this.owner = NULL; 28 this.recursion = 0; 29 29 } 30 30 … … 40 40 } 41 41 42 void ?{}( monitor_guard_t *this, monitor_desc ** m, int count );43 void ^?{}( monitor_guard_t *this );42 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count ); 43 void ^?{}( monitor_guard_t & this ); 44 44 45 45 //----------------------------------------------------------------------------- … … 66 66 }; 67 67 68 void ?{}( __condition_blocked_queue_t *);68 void ?{}( __condition_blocked_queue_t & ); 69 69 void append( __condition_blocked_queue_t *, __condition_node_t * ); 70 70 __condition_node_t * pop_head( __condition_blocked_queue_t * ); … … 76 76 }; 77 77 78 static inline void ?{}( condition *this ) {79 this ->monitors = NULL;80 this ->monitor_count = 0;78 static inline void ?{}( condition & this ) { 79 this.monitors = NULL; 80 this.monitor_count = 0; 81 81 } 82 82 83 static inline void ^?{}( condition *this ) {84 free( this ->monitors );83 static inline void ^?{}( condition & this ) { 84 free( this.monitors ); 85 85 } 86 86 -
src/libcfa/concurrency/monitor.c
r795d450 r242a902 140 140 } 141 141 142 void ?{}( monitor_guard_t *this, monitor_desc ** m, int count ) {143 this ->m = m;144 this ->count = count;145 qsort(this ->m, count);146 enter( this ->m, this->count );147 148 this ->prev_mntrs = this_thread->current_monitors;149 this ->prev_count = this_thread->current_monitor_count;142 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count ) { 143 this.m = m; 144 this.count = count; 145 qsort(this.m, count); 146 enter( this.m, this.count ); 147 148 this.prev_mntrs = this_thread->current_monitors; 149 this.prev_count = this_thread->current_monitor_count; 150 150 151 151 this_thread->current_monitors = m; … … 153 153 } 154 154 155 void ^?{}( monitor_guard_t *this ) {156 leave( this ->m, this->count );157 158 this_thread->current_monitors = this ->prev_mntrs;159 this_thread->current_monitor_count = this ->prev_count;160 } 161 162 void ?{}(__condition_node_t *this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) {163 this ->waiting_thread = waiting_thread;164 this ->count = count;165 this ->next = NULL;166 this ->user_info = user_info;167 } 168 169 void ?{}(__condition_criterion_t *this ) {170 this ->ready = false;171 this ->target = NULL;172 this ->owner = NULL;173 this ->next = NULL;174 } 175 176 void ?{}(__condition_criterion_t *this, monitor_desc * target, __condition_node_t * owner ) {177 this ->ready = false;178 this ->target = target;179 this ->owner = owner;180 this ->next = NULL;155 void ^?{}( monitor_guard_t & this ) { 156 leave( this.m, this.count ); 157 158 this_thread->current_monitors = this.prev_mntrs; 159 this_thread->current_monitor_count = this.prev_count; 160 } 161 162 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) { 163 this.waiting_thread = waiting_thread; 164 this.count = count; 165 this.next = NULL; 166 this.user_info = user_info; 167 } 168 169 void ?{}(__condition_criterion_t & this ) { 170 this.ready = false; 171 this.target = NULL; 172 this.owner = NULL; 173 this.next = NULL; 174 } 175 176 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner ) { 177 this.ready = false; 178 this.target = target; 179 this.owner = owner; 180 this.next = NULL; 181 181 } 182 182 … … 506 506 } 507 507 508 void ?{}( __condition_blocked_queue_t *this ) {509 this ->head = NULL;510 this ->tail = &this->head;508 void ?{}( __condition_blocked_queue_t & this ) { 509 this.head = NULL; 510 this.tail = &this.head; 511 511 } 512 512 -
src/libcfa/concurrency/preemption.c
r795d450 r242a902 230 230 } 231 231 232 void ?{}( preemption_scope *this, processor * proc ) {233 ( &this->alarm){ proc };234 this ->proc = proc;235 this ->proc->preemption_alarm = &this->alarm;236 update_preemption( this ->proc, this->proc->preemption );237 } 238 239 void ^?{}( preemption_scope *this ) {232 void ?{}( preemption_scope & this, processor * proc ) { 233 (this.alarm){ proc }; 234 this.proc = proc; 235 this.proc->preemption_alarm = &this.alarm; 236 update_preemption( this.proc, this.proc->preemption ); 237 } 238 239 void ^?{}( preemption_scope & this ) { 240 240 disable_interrupts(); 241 241 242 update_preemption( this ->proc, 0 );242 update_preemption( this.proc, 0 ); 243 243 } 244 244 -
src/libcfa/concurrency/preemption.h
r795d450 r242a902 32 32 }; 33 33 34 void ?{}( preemption_scope *this, processor * proc );35 void ^?{}( preemption_scope *this );34 void ?{}( preemption_scope & this, processor * proc ); 35 void ^?{}( preemption_scope & this ); 36 36 37 37 #endif //PREEMPTION_H -
src/libcfa/concurrency/thread
r795d450 r242a902 29 29 // Anything that is resumed is a coroutine. 30 30 trait is_thread(dtype T) { 31 void ^?{}(T *mutex this);31 void ^?{}(T& mutex this); 32 32 void main(T* this); 33 33 thread_desc* get_thread(T* this); … … 61 61 //----------------------------------------------------------------------------- 62 62 // Ctors and dtors 63 void ?{}(thread_desc *this);64 void ^?{}(thread_desc *this);63 void ?{}(thread_desc& this); 64 void ^?{}(thread_desc& this); 65 65 66 66 //----------------------------------------------------------------------------- … … 72 72 }; 73 73 74 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T *); } )75 void ?{}( scoped(T) *this );74 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } ) 75 void ?{}( scoped(T)& this ); 76 76 77 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T *, P); } )78 void ?{}( scoped(T) *this, P params );77 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } ) 78 void ?{}( scoped(T)& this, P params ); 79 79 80 80 forall( dtype T | sized(T) | is_thread(T) ) 81 void ^?{}( scoped(T) *this );81 void ^?{}( scoped(T)& this ); 82 82 83 83 void yield(); -
src/libcfa/concurrency/thread.c
r795d450 r242a902 33 33 // Thread ctors and dtors 34 34 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;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; 41 41 42 this ->current_monitors = &this->mon;43 this ->current_monitor_count = 1;42 this.current_monitors = &this.mon; 43 this.current_monitor_count = 1; 44 44 } 45 45 46 void ^?{}(thread_desc *this) {47 ^( &this->cor){};46 void ^?{}(thread_desc& this) { 47 ^(this.cor){}; 48 48 } 49 49 50 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T *); } )51 void ?{}( scoped(T) *this ) {52 ( &this->handle){};53 __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); 54 54 } 55 55 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);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); 60 60 } 61 61 62 62 forall( dtype T | sized(T) | is_thread(T) ) 63 void ^?{}( scoped(T) *this ) {64 ^( &this->handle){};63 void ^?{}( scoped(T)& this ) { 64 ^(this.handle){}; 65 65 } 66 66 -
src/libcfa/containers/result
r795d450 r242a902 35 35 36 36 forall(otype T, otype E) 37 void ?{}(result(T, E) *this);37 void ?{}(result(T, E) & this); 38 38 39 39 forall(otype T, otype E) 40 void ?{}(result(T, E) *this, one_t, T value);40 void ?{}(result(T, E) & this, one_t, T value); 41 41 42 42 forall(otype T, otype E) 43 void ?{}(result(T, E) *this, zero_t, E error);43 void ?{}(result(T, E) & this, zero_t, E error); 44 44 45 45 forall(otype T, otype E) 46 void ?{}(result(T, E) *this, result(T, E) other);46 void ?{}(result(T, E) & this, result(T, E) other); 47 47 48 48 forall(otype T, otype E) 49 void ^?{}(result(T, E) *this);49 void ^?{}(result(T, E) & this); 50 50 51 51 forall(otype T, otype E) 52 result(T, E) ?=?(result(T, E) *this, result(T, E) other);52 result(T, E) ?=?(result(T, E) & this, result(T, E) other); 53 53 54 54 forall(otype T, otype E) -
src/libcfa/containers/result.c
r795d450 r242a902 19 19 20 20 forall(otype T, otype E) 21 void ?{}(result(T, E) *this) {22 this ->has_value = false;23 ( &this->error){};21 void ?{}(result(T, E) & this) { 22 this.has_value = false; 23 (this.error){}; 24 24 } 25 25 26 26 forall(otype T, otype E) 27 void ?{}(result(T, E) *this, one_t, T value) {28 this ->has_value = true;29 ( &this->value){value};27 void ?{}(result(T, E) & this, one_t, T value) { 28 this.has_value = true; 29 (this.value){value}; 30 30 } 31 31 32 32 forall(otype T, otype E) 33 void ?{}(result(T, E) *this, zero_t, E error) {34 this ->has_value = false;35 ( &this->error){error};33 void ?{}(result(T, E) & this, zero_t, E error) { 34 this.has_value = false; 35 (this.error){error}; 36 36 } 37 37 38 38 forall(otype T, otype E) 39 void ?{}(result(T, E) *this, result(T, E) other) {40 this ->has_value = other.has_value;39 void ?{}(result(T, E) & this, result(T, E) other) { 40 this.has_value = other.has_value; 41 41 if (other.has_value) { 42 ( &this->value){other.value};42 (this.value){other.value}; 43 43 } else { 44 ( &this->error){other.error};44 (this.error){other.error}; 45 45 } 46 46 } 47 47 48 48 forall(otype T, otype E) 49 result(T, E) ?=?(result(T, E) *this, result(T, E) that) {50 if (this ->has_value & that.has_value) {51 this ->value = that.value;52 } else if (this ->has_value) {53 ^( &this->value){};54 this ->has_value = false;55 ( &this->error){that.error};49 result(T, E) ?=?(result(T, E) & this, result(T, E) that) { 50 if (this.has_value & that.has_value) { 51 this.value = that.value; 52 } else if (this.has_value) { 53 ^(this.value){}; 54 this.has_value = false; 55 (this.error){that.error}; 56 56 } else if (that.has_value) { 57 ^( &this->error){};58 this ->has_value = true;59 ( &this->value){that.value};57 ^(this.error){}; 58 this.has_value = true; 59 (this.value){that.value}; 60 60 } else { 61 this ->error = that.error;61 this.error = that.error; 62 62 } 63 63 } 64 64 65 65 forall(otype T, otype E) 66 void ^?{}(result(T, E) *this) {67 if (this ->has_value) {68 ^( &this->value){};66 void ^?{}(result(T, E) & this) { 67 if (this.has_value) { 68 ^(this.value){}; 69 69 } else { 70 ^( &this->error){};70 ^(this.error){}; 71 71 } 72 72 } … … 109 109 this->value = value; 110 110 } else { 111 ^( &this->error){};111 ^(this->error){}; 112 112 this->has_value = true; 113 ( &this->value){value};113 (this->value){value}; 114 114 } 115 115 } … … 118 118 void set_error(result(T, E) * this, E error) { 119 119 if (this->has_value) { 120 ^( &this->value){};120 ^(this->value){}; 121 121 this->has_value = false; 122 ( &this->error){error};122 (this->error){error}; 123 123 } else { 124 124 this->error = error; -
src/tests/coroutine.c
r795d450 r242a902 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 // fibonacci.c -- 8 // 6 // 7 // fibonacci.c -- 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu Jun 8 07:29:37 2017 … … 12 12 // Last Modified On : Thu Jun 8 07:37:12 2017 13 13 // Update Count : 5 14 // 14 // 15 15 16 16 #include <fstream> … … 21 21 }; 22 22 23 void ?{}( Fibonacci *this ) {24 this ->fn = 0;23 void ?{}( Fibonacci & this ) { 24 this.fn = 0; 25 25 } 26 26 -
src/tests/monitor.c
r795d450 r242a902 8 8 }; 9 9 10 void ?{}(global_t *this) {11 this ->value = 0;10 void ?{}(global_t & this) { 11 this.value = 0; 12 12 } 13 13 -
src/tests/thread.c
r795d450 r242a902 7 7 thread Second { semaphore* lock; }; 8 8 9 void ?{}( First * this, semaphore* lock ) { this->lock = lock; }10 void ?{}( Second * this, semaphore* lock ) { this->lock = lock; }9 void ?{}( First & this, semaphore* lock ) { this.lock = lock; } 10 void ?{}( Second & this, semaphore* lock ) { this.lock = lock; } 11 11 12 12 void main(First* this) {
Note: See TracChangeset
for help on using the changeset viewer.