Changeset 9c31349 for src/libcfa/concurrency
- Timestamp:
- Mar 21, 2017, 3:11:30 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:
- da6d4566
- Parents:
- cb0e6de
- Location:
- src/libcfa/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.h
rcb0e6de r9c31349 38 38 }; 39 39 40 struct signal_once {41 volatile bool condition;42 struct spinlock lock;43 struct simple_thread_list blocked;44 };45 46 40 #ifdef __CFORALL__ 47 41 extern "Cforall" { … … 52 46 void ?{}(spinlock * this); 53 47 void ^?{}(spinlock * this); 54 55 void ?{}(signal_once * this);56 void ^?{}(signal_once * this);57 48 } 58 49 #endif … … 88 79 struct thread_desc { 89 80 struct coroutine_desc cor; // coroutine body used to store context 90 struct monitor_desc mon; 91 struct signal_once terminated; // indicate if execuation state is not halted 81 struct monitor_desc mon; // monitor body used for mutual exclusion 92 82 struct thread_desc * next; // instrusive link field for threads 93 83 }; -
src/libcfa/concurrency/kernel
rcb0e6de r9c31349 30 30 void lock( spinlock * ); 31 31 void unlock( spinlock * ); 32 33 struct signal_once { 34 volatile bool condition; 35 struct spinlock lock; 36 struct simple_thread_list blocked; 37 }; 38 39 void ?{}(signal_once * this); 40 void ^?{}(signal_once * this); 32 41 33 42 void wait( signal_once * ); -
src/libcfa/concurrency/thread.c
rcb0e6de r9c31349 35 35 void start( T* this ); 36 36 37 forall( dtype T | is_thread(T) )38 void stop( T* this );39 40 37 //----------------------------------------------------------------------------- 41 38 // Thread ctors and dtors … … 46 43 this->mon.owner = this; 47 44 this->mon.recursion = 1; 48 (&this->terminated){};49 45 this->next = NULL; 50 46 } … … 68 64 forall( dtype T | sized(T) | is_thread(T) ) 69 65 void ^?{}( scoped(T)* this ) { 70 stop(&this->handle);71 66 ^(&this->handle){}; 72 67 } … … 88 83 89 84 ScheduleThread(thrd_h); 90 }91 92 forall( dtype T | is_thread(T) )93 void stop( T* this ) {94 // wait( & get_thread(this)->terminated );95 85 } 96 86 … … 118 108 } 119 109 120 // C Helper to signal the termination of a thread_desc121 // Used in invoke.c122 extern "C" {123 void __thread_signal_termination( thread_desc * this ) {124 this->cor.state = Halted;125 LIB_DEBUG_PRINTF("Thread end : %p\n", this);126 signal( &this->terminated );127 }128 }129 130 110 // Local Variables: // 131 111 // mode: c //
Note: See TracChangeset
for help on using the changeset viewer.