Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/thread.cfa

    rfd54fef r9cc3a18  
    3939        link.next = 0p;
    4040        link.prev = 0p;
    41         link.preferred = -1;
    4241        #if defined( __CFA_WITH_VERIFY__ )
    4342                canary = 0x0D15EA5E0D15EA5Ep;
     
    6261}
    6362
    64 FORALL_DATA_INSTANCE(ThreadCancelled, (thread_t &), (thread_t))
     63EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled);
    6564
    6665forall(T &)
     
    7372forall(T &)
    7473const char * msg(ThreadCancelled(T) *) {
    75         return "ThreadCancelled";
     74        return "ThreadCancelled(...)";
    7675}
    7776
    7877forall(T &)
    7978static void default_thread_cancel_handler(ThreadCancelled(T) & ) {
     79        // Improve this error message, can I do formatting?
    8080        abort( "Unhandled thread cancellation.\n" );
    8181}
    8282
    83 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)))
     83static void default_thread_cancel_handler(SomeThreadCancelled & ) {
     84        // Improve this error message, can I do formatting?
     85        abort( "Unhandled thread cancellation.\n" );
     86}
     87
     88forall(T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled))
    8489void ?{}( 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);
    8792        $thread * desc = get_thread(thrd);
    8893
    8994        // Setup the monitor guard
    9095        void (*dtor)(T& mutex this) = ^?{};
    91         bool join = cancelHandler != (void(*)(ThreadCancelled(T)&))0;
     96        bool join = cancelHandler != (void(*)(SomeThreadCancelled&))0;
    9297        (this.mg){&m, (void(*)())dtor, join};
    9398
     
    103108        }
    104109        desc->state = Cancelled;
    105         void(*defaultResumptionHandler)(ThreadCancelled(T) &) =
     110        void(*defaultResumptionHandler)(SomeThreadCancelled &) =
    106111                join ? cancelHandler : default_thread_cancel_handler;
    107112
    108         ThreadCancelled(T) except;
    109113        // 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;
    111116        except.the_thread = &thrd;
    112117        except.the_exception = __cfaehm_cancellation_exception( cancellation );
    113         throwResume except;
     118        // Why is this cast required?
     119        throwResume (SomeThreadCancelled &)except;
    114120
    115121        except.the_exception->virtual_table->free( except.the_exception );
     
    158164
    159165//-----------------------------------------------------------------------------
    160 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)))
     166forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled))
    161167T & join( T & this ) {
    162168        thread_dtor_guard_t guard = { this, defaultResumptionHandler };
Note: See TracChangeset for help on using the changeset viewer.