Ignore:
Timestamp:
Apr 9, 2021, 2:11:43 PM (8 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
b91bfde
Parents:
e07b589
Message:

Major exception update, seperating type-ids from virtual tables. The major interface changes are done. There is a regression of ?Cancelled(T) to Some?Cancelled. There is some bits of code for the new verion of the ?Cancelled(T) interface already there. Not connected yet but I just reached the limit of what I wanted to do in one commit and then spent over a day cleaning up, so it will replace Some?Cancelled in a future commit.

File:
1 edited

Legend:

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

    re07b589 recfd758  
    6262}
    6363
    64 FORALL_DATA_INSTANCE(ThreadCancelled, (thread_t &), (thread_t))
     64EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled);
    6565
    6666forall(T &)
     
    7373forall(T &)
    7474const char * msg(ThreadCancelled(T) *) {
    75         return "ThreadCancelled";
     75        return "ThreadCancelled(...)";
    7676}
    7777
    7878forall(T &)
    7979static void default_thread_cancel_handler(ThreadCancelled(T) & ) {
     80        // Improve this error message, can I do formatting?
    8081        abort( "Unhandled thread cancellation.\n" );
    8182}
    8283
    83 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T)))
     84static void default_thread_cancel_handler(SomeThreadCancelled & ) {
     85        // Improve this error message, can I do formatting?
     86        abort( "Unhandled thread cancellation.\n" );
     87}
     88
     89forall(T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled))
    8490void ?{}( 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);
    8793        $thread * desc = get_thread(thrd);
    8894
    8995        // Setup the monitor guard
    9096        void (*dtor)(T& mutex this) = ^?{};
    91         bool join = cancelHandler != (void(*)(ThreadCancelled(T)&))0;
     97        bool join = cancelHandler != (void(*)(SomeThreadCancelled&))0;
    9298        (this.mg){&m, (void(*)())dtor, join};
    9399
     
    103109        }
    104110        desc->state = Cancelled;
    105         void(*defaultResumptionHandler)(ThreadCancelled(T) &) =
     111        void(*defaultResumptionHandler)(SomeThreadCancelled &) =
    106112                join ? cancelHandler : default_thread_cancel_handler;
    107113
    108         ThreadCancelled(T) except;
    109114        // 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;
    111117        except.the_thread = &thrd;
    112118        except.the_exception = __cfaehm_cancellation_exception( cancellation );
    113         throwResume except;
     119        // Why is this cast required?
     120        throwResume (SomeThreadCancelled &)except;
    114121
    115122        except.the_exception->virtual_table->free( except.the_exception );
     
    158165
    159166//-----------------------------------------------------------------------------
    160 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T)))
     167forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled))
    161168T & join( T & this ) {
    162169        thread_dtor_guard_t guard = { this, defaultResumptionHandler };
Note: See TracChangeset for help on using the changeset viewer.