Changeset 8edbe40


Ignore:
Timestamp:
Apr 23, 2021, 4:26:52 PM (3 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
Children:
50f6afb
Parents:
aaf92de
Message:

SomeThreadCancelled? -> ThreadCancelled?: thread cancellations carry type information again.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/clib/cfathread.cfa

    raaf92de r8edbe40  
    5050
    5151cfathread_vtable _cfathread_vtable_instance;
     52
     53cfathread_vtable & const _default_vtable = _cfathread_vtable_instance;
    5254
    5355cfathread_vtable const & get_exception_vtable(cfathread_exception *) {
  • libcfa/src/concurrency/thread.cfa

    raaf92de r8edbe40  
    6161}
    6262
    63 EHM_VIRTUAL_TABLE(SomeThreadCancelled, std_thread_cancelled);
    64 
    6563forall(T &)
    6664void copy(ThreadCancelled(T) * dst, ThreadCancelled(T) * src) {
     
    8179}
    8280
    83 static void default_thread_cancel_handler(SomeThreadCancelled & ) {
    84         // Improve this error message, can I do formatting?
    85         abort( "Unhandled thread cancellation.\n" );
    86 }
    87 
    88 forall(T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled))
     81forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
     82    | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; })
    8983void ?{}( thread_dtor_guard_t & this,
    90                 T & thrd, void(*cancelHandler)(SomeThreadCancelled &)) {
     84                T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) {
    9185        $monitor * m = get_monitor(thrd);
    9286        $thread * desc = get_thread(thrd);
     
    9488        // Setup the monitor guard
    9589        void (*dtor)(T& mutex this) = ^?{};
    96         bool join = cancelHandler != (void(*)(SomeThreadCancelled&))0;
     90        bool join = cancelHandler != (void(*)(ThreadCancelled(T)&))0;
    9791        (this.mg){&m, (void(*)())dtor, join};
    9892
     
    108102        }
    109103        desc->state = Cancelled;
    110         void(*defaultResumptionHandler)(SomeThreadCancelled &) =
     104        void(*defaultResumptionHandler)(ThreadCancelled(T) &) =
    111105                join ? cancelHandler : default_thread_cancel_handler;
    112106
    113107        // TODO: Remove explitate vtable set once trac#186 is fixed.
    114         SomeThreadCancelled except;
    115         except.virtual_table = &std_thread_cancelled;
     108        ThreadCancelled(T) except;
     109        except.virtual_table = &_default_vtable;
    116110        except.the_thread = &thrd;
    117111        except.the_exception = __cfaehm_cancellation_exception( cancellation );
    118112        // Why is this cast required?
    119         throwResume (SomeThreadCancelled &)except;
     113        throwResume (ThreadCancelled(T) &)except;
    120114
    121115        except.the_exception->virtual_table->free( except.the_exception );
     
    164158
    165159//-----------------------------------------------------------------------------
    166 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled))
     160forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
     161    | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; })
    167162T & join( T & this ) {
    168163        thread_dtor_guard_t guard = { this, defaultResumptionHandler };
  • libcfa/src/concurrency/thread.hfa

    raaf92de r8edbe40  
    3131        $thread* get_thread(T& this);
    3232};
    33 
    34 EHM_EXCEPTION(SomeThreadCancelled) (
    35         void * the_thread;
    36         exception_t * the_exception;
    37 );
    38 
    39 EHM_EXTERN_VTABLE(SomeThreadCancelled, std_thread_cancelled);
    4033
    4134EHM_FORALL_EXCEPTION(ThreadCancelled, (thread_t &), (thread_t)) (
     
    8679};
    8780
    88 forall( T & | is_thread(T) | IS_EXCEPTION(SomeThreadCancelled) )
    89 void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(SomeThreadCancelled &) );
     81forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
     82    | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; } )
     83void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) );
    9084void ^?{}( thread_dtor_guard_t & this );
    9185
     
    132126//----------
    133127// join
    134 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(SomeThreadCancelled) )
     128forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
     129    | { _EHM_VTABLE_TYPE(ThreadCancelled)(T) & const _default_vtable; } )
    135130T & join( T & this );
    136131
  • src/Concurrency/Keywords.cc

    raaf92de r8edbe40  
    501501                        vtable_decl->makeInst( move( poly_args ) ) );
    502502                declsToAddBefore.push_back( vtable_object );
    503                 declsToAddAfter.push_back(
     503                declsToAddBefore.push_back(
    504504                        new ObjectDecl(
    505505                                Virtual::concurrentDefaultVTableName(),
  • tests/exceptions/cancel/thread.cfa

    raaf92de r8edbe40  
    2626                join(cancel);
    2727                printf("4");
    28         } catchResume (SomeThreadCancelled * error) {
     28        } catchResume (ThreadCancelled(WillCancel) * error) {
    2929                printf("2");
    3030                if ((virtual internal_error *)error->the_exception) {
     
    4343                }
    4444                printf("4");
    45         } catchResume (SomeThreadCancelled * error) {
     45        } catchResume (ThreadCancelled(WillCancel) * error) {
    4646                printf("2");
    4747                if ((virtual internal_error *)error->the_exception) {
Note: See TracChangeset for help on using the changeset viewer.