Changeset 342be43 for libcfa/src/concurrency/thread.cfa
- Timestamp:
- Oct 26, 2020, 5:10:02 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- cb25fc9
- Parents:
- ab8c6a6
- File:
-
- 1 edited
-
libcfa/src/concurrency/thread.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
rab8c6a6 r342be43 73 73 } 74 74 75 struct __cfaehm_node {76 struct _Unwind_Exception unwind_exception;77 struct __cfaehm_node * next;78 int handler_index;79 };80 81 75 forall(dtype T) 82 76 static void default_thread_cancel_handler(ThreadCancelled(T) & ) { … … 91 85 bool join = defaultResumptionHandler != (void(*)(ThreadCancelled(T)&))0; 92 86 (this.mg){&m, (void(*)())dtor, join}; 93 {94 $thread * desc = get_thread(thrd);95 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation;96 if ( likely(0p == cancellation) ) {97 return;98 } else if ( Cancelled == desc->state ) {99 return;100 }101 desc->state = Cancelled;102 if (!join) {103 defaultResumptionHandler = default_thread_cancel_handler;104 }105 ThreadCancelled(T) except;106 // TODO: Remove explitate vtable set once trac#186 is fixed.107 except.virtual_table = &get_exception_vtable(&except);108 except.the_thread = &thrd;109 except.the_exception = (exception_t *)(1 + (__cfaehm_node *)cancellation);110 throwResume except;111 87 112 except.the_exception->virtual_table->free( except.the_exception ); 113 free( cancellation ); 114 desc->self_cor.cancellation = 0p; 88 // After the guard set-up and any wait, check for cancellation. 89 $thread * desc = get_thread(thrd); 90 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation; 91 if ( likely( 0p == cancellation ) ) { 92 return; 93 } else if ( Cancelled == desc->state ) { 94 return; 115 95 } 96 desc->state = Cancelled; 97 if (!join) { 98 defaultResumptionHandler = default_thread_cancel_handler; 99 } 100 101 ThreadCancelled(T) except; 102 // TODO: Remove explitate vtable set once trac#186 is fixed. 103 except.virtual_table = &get_exception_vtable(&except); 104 except.the_thread = &thrd; 105 except.the_exception = __cfaehm_cancellation_exception( cancellation ); 106 throwResume except; 107 108 except.the_exception->virtual_table->free( except.the_exception ); 109 free( cancellation ); 110 desc->self_cor.cancellation = 0p; 116 111 } 117 112
Note:
See TracChangeset
for help on using the changeset viewer.