- File:
-
- 1 edited
-
libcfa/src/concurrency/thread.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
rfd54fef r9cc3a18 39 39 link.next = 0p; 40 40 link.prev = 0p; 41 link.preferred = -1;42 41 #if defined( __CFA_WITH_VERIFY__ ) 43 42 canary = 0x0D15EA5E0D15EA5Ep; … … 62 61 } 63 62 64 FORALL_DATA_INSTANCE(ThreadCancelled, (thread_t &), (thread_t)) 63 EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled); 65 64 66 65 forall(T &) … … 73 72 forall(T &) 74 73 const char * msg(ThreadCancelled(T) *) { 75 return "ThreadCancelled ";74 return "ThreadCancelled(...)"; 76 75 } 77 76 78 77 forall(T &) 79 78 static void default_thread_cancel_handler(ThreadCancelled(T) & ) { 79 // Improve this error message, can I do formatting? 80 80 abort( "Unhandled thread cancellation.\n" ); 81 81 } 82 82 83 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))) 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)) 84 89 void ?{}( thread_dtor_guard_t & this, 85 T & thrd, void(*cancelHandler)( ThreadCancelled(T)&)) {86 $monitor * m = get_monitor(thrd);90 T & thrd, void(*cancelHandler)(SomeThreadCancelled &)) { 91 $monitor * m = get_monitor(thrd); 87 92 $thread * desc = get_thread(thrd); 88 93 89 94 // Setup the monitor guard 90 95 void (*dtor)(T& mutex this) = ^?{}; 91 bool join = cancelHandler != (void(*)( ThreadCancelled(T)&))0;96 bool join = cancelHandler != (void(*)(SomeThreadCancelled&))0; 92 97 (this.mg){&m, (void(*)())dtor, join}; 93 98 … … 103 108 } 104 109 desc->state = Cancelled; 105 void(*defaultResumptionHandler)( ThreadCancelled(T) &) =110 void(*defaultResumptionHandler)(SomeThreadCancelled &) = 106 111 join ? cancelHandler : default_thread_cancel_handler; 107 112 108 ThreadCancelled(T) except;109 113 // TODO: Remove explitate vtable set once trac#186 is fixed. 110 except.virtual_table = &get_exception_vtable(&except); 114 SomeThreadCancelled except; 115 except.virtual_table = &std_thread_cancelled; 111 116 except.the_thread = &thrd; 112 117 except.the_exception = __cfaehm_cancellation_exception( cancellation ); 113 throwResume except; 118 // Why is this cast required? 119 throwResume (SomeThreadCancelled &)except; 114 120 115 121 except.the_exception->virtual_table->free( except.the_exception ); … … 158 164 159 165 //----------------------------------------------------------------------------- 160 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION( ThreadCancelled, (T)))166 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled)) 161 167 T & join( T & this ) { 162 168 thread_dtor_guard_t guard = { this, defaultResumptionHandler };
Note:
See TracChangeset
for help on using the changeset viewer.