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