Changeset 8edbe40
- Timestamp:
- Apr 23, 2021, 4:26:52 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 50f6afb
- Parents:
- aaf92de
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/clib/cfathread.cfa
raaf92de r8edbe40 50 50 51 51 cfathread_vtable _cfathread_vtable_instance; 52 53 cfathread_vtable & const _default_vtable = _cfathread_vtable_instance; 52 54 53 55 cfathread_vtable const & get_exception_vtable(cfathread_exception *) { -
libcfa/src/concurrency/thread.cfa
raaf92de r8edbe40 61 61 } 62 62 63 EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled);64 65 63 forall(T &) 66 64 void copy(ThreadCancelled(T) * dst, ThreadCancelled(T) * src) { … … 81 79 } 82 80 83 static void default_thread_cancel_handler(SomeThreadCancelled & ) { 84 // Improve this error message, can I do formatting? 85 abort( "Unhandled thread cancellation.\n" ); 86 } 87 88 forall(T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled)) 81 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)) 82 | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; }) 89 83 void ?{}( thread_dtor_guard_t & this, 90 T & thrd, void(*cancelHandler)( SomeThreadCancelled&)) {84 T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) { 91 85 $monitor * m = get_monitor(thrd); 92 86 $thread * desc = get_thread(thrd); … … 94 88 // Setup the monitor guard 95 89 void (*dtor)(T& mutex this) = ^?{}; 96 bool join = cancelHandler != (void(*)( SomeThreadCancelled&))0;90 bool join = cancelHandler != (void(*)(ThreadCancelled(T)&))0; 97 91 (this.mg){&m, (void(*)())dtor, join}; 98 92 … … 108 102 } 109 103 desc->state = Cancelled; 110 void(*defaultResumptionHandler)( SomeThreadCancelled&) =104 void(*defaultResumptionHandler)(ThreadCancelled(T) &) = 111 105 join ? cancelHandler : default_thread_cancel_handler; 112 106 113 107 // TODO: Remove explitate vtable set once trac#186 is fixed. 114 SomeThreadCancelledexcept;115 except.virtual_table = & std_thread_cancelled;108 ThreadCancelled(T) except; 109 except.virtual_table = &_default_vtable; 116 110 except.the_thread = &thrd; 117 111 except.the_exception = __cfaehm_cancellation_exception( cancellation ); 118 112 // Why is this cast required? 119 throwResume ( SomeThreadCancelled&)except;113 throwResume (ThreadCancelled(T) &)except; 120 114 121 115 except.the_exception->virtual_table->free( except.the_exception ); … … 164 158 165 159 //----------------------------------------------------------------------------- 166 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled)) 160 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)) 161 | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; }) 167 162 T & join( T & this ) { 168 163 thread_dtor_guard_t guard = { this, defaultResumptionHandler }; -
libcfa/src/concurrency/thread.hfa
raaf92de r8edbe40 31 31 $thread* get_thread(T& this); 32 32 }; 33 34 EHM_EXCEPTION(SomeThreadCancelled) (35 void * the_thread;36 exception_t * the_exception;37 );38 39 EHM_EXTERN_VTABLE(SomeThreadCancelled, std_thread_cancelled);40 33 41 34 EHM_FORALL_EXCEPTION(ThreadCancelled, (thread_t &), (thread_t)) ( … … 86 79 }; 87 80 88 forall( T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled) ) 89 void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(SomeThreadCancelled &) ); 81 forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)) 82 | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; } ) 83 void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) ); 90 84 void ^?{}( thread_dtor_guard_t & this ); 91 85 … … 132 126 //---------- 133 127 // join 134 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled) ) 128 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)) 129 | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; } ) 135 130 T & join( T & this ); 136 131 -
src/Concurrency/Keywords.cc
raaf92de r8edbe40 501 501 vtable_decl->makeInst( move( poly_args ) ) ); 502 502 declsToAddBefore.push_back( vtable_object ); 503 declsToAdd After.push_back(503 declsToAddBefore.push_back( 504 504 new ObjectDecl( 505 505 Virtual::concurrentDefaultVTableName(), -
tests/exceptions/cancel/thread.cfa
raaf92de r8edbe40 26 26 join(cancel); 27 27 printf("4"); 28 } catchResume ( SomeThreadCancelled* error) {28 } catchResume (ThreadCancelled(WillCancel) * error) { 29 29 printf("2"); 30 30 if ((virtual internal_error *)error->the_exception) { … … 43 43 } 44 44 printf("4"); 45 } catchResume ( SomeThreadCancelled* error) {45 } catchResume (ThreadCancelled(WillCancel) * error) { 46 46 printf("2"); 47 47 if ((virtual internal_error *)error->the_exception) {
Note: See TracChangeset
for help on using the changeset viewer.