Ignore:
Timestamp:
Oct 26, 2020, 5:10:02 PM (6 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
cb25fc9
Parents:
ab8c6a6
Message:

Some exception clean-up that did not require any drastic changes.

File:
1 edited

Legend:

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

    rab8c6a6 r342be43  
    7373}
    7474
    75 struct __cfaehm_node {
    76         struct _Unwind_Exception unwind_exception;
    77         struct __cfaehm_node * next;
    78         int handler_index;
    79 };
    80 
    8175forall(dtype T)
    8276static void default_thread_cancel_handler(ThreadCancelled(T) & ) {
     
    9185        bool join = defaultResumptionHandler != (void(*)(ThreadCancelled(T)&))0;
    9286        (this.mg){&m, (void(*)())dtor, join};
    93         {
    94                 $thread * desc = get_thread(thrd);
    95                 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation;
    96                 if ( likely(0p == cancellation) ) {
    97                         return;
    98                 } else if ( Cancelled == desc->state ) {
    99                         return;
    100                 }
    101                 desc->state = Cancelled;
    102                 if (!join) {
    103                         defaultResumptionHandler = default_thread_cancel_handler;
    104                 }
    105                 ThreadCancelled(T) except;
    106                 // TODO: Remove explitate vtable set once trac#186 is fixed.
    107                 except.virtual_table = &get_exception_vtable(&except);
    108                 except.the_thread = &thrd;
    109                 except.the_exception = (exception_t *)(1 + (__cfaehm_node *)cancellation);
    110                 throwResume except;
    11187
    112                 except.the_exception->virtual_table->free( except.the_exception );
    113                 free( cancellation );
    114                 desc->self_cor.cancellation = 0p;
     88        // After the guard set-up and any wait, check for cancellation.
     89        $thread * desc = get_thread(thrd);
     90        struct _Unwind_Exception * cancellation = desc->self_cor.cancellation;
     91        if ( likely( 0p == cancellation ) ) {
     92                return;
     93        } else if ( Cancelled == desc->state ) {
     94                return;
    11595        }
     96        desc->state = Cancelled;
     97        if (!join) {
     98                defaultResumptionHandler = default_thread_cancel_handler;
     99        }
     100
     101        ThreadCancelled(T) except;
     102        // TODO: Remove explitate vtable set once trac#186 is fixed.
     103        except.virtual_table = &get_exception_vtable(&except);
     104        except.the_thread = &thrd;
     105        except.the_exception = __cfaehm_cancellation_exception( cancellation );
     106        throwResume except;
     107
     108        except.the_exception->virtual_table->free( except.the_exception );
     109        free( cancellation );
     110        desc->self_cor.cancellation = 0p;
    116111}
    117112
Note: See TracChangeset for help on using the changeset viewer.