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