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