Changeset c3b9d639


Ignore:
Timestamp:
May 26, 2022, 10:21:17 AM (5 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
5416b44
Parents:
c715e5f
Message:

Clean-up the exception interface. It should be slightly more like the final - non-macro - interface.

Files:
6 edited

Legend:

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

    rc715e5f rc3b9d639  
    6262forall(T & | is_coroutine(T))
    6363void __cfaehm_cancelled_coroutine(
    64                 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) ) libcfa_public {
     64                T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) ) libcfa_public {
    6565        verify( desc->cancellation );
    6666        desc->state = Cancelled;
     
    146146// Part of the Public API
    147147// Not inline since only ever called once per coroutine
    148 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
     148forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
    149149void prime(T& cor) libcfa_public {
    150150        coroutine$* this = get_coroutine(cor);
  • libcfa/src/concurrency/coroutine.hfa

    rc715e5f rc3b9d639  
    3838// Anything that implements this trait can be resumed.
    3939// Anything that is resumed is a coroutine.
    40 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
     40trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) {
    4141        void main(T & this);
    4242        coroutine$ * get_coroutine(T & this);
     
    6161//-----------------------------------------------------------------------------
    6262// Public coroutine API
    63 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
     63forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
    6464void prime(T & cor);
    6565
     
    140140forall(T & | is_coroutine(T))
    141141void __cfaehm_cancelled_coroutine(
    142         T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) );
     142        T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) );
    143143
    144144// Resume implementation inlined for performance
    145 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
     145forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
    146146static inline T & resume(T & cor) {
    147147        // optimization : read TLS once and reuse it
  • libcfa/src/concurrency/thread.cfa

    rc715e5f rc3b9d639  
    8989}
    9090
    91 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
    92     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     91forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T))
     92    | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    9393void ?{}( thread_dtor_guard_t & this,
    9494                T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) {
     
    168168
    169169//-----------------------------------------------------------------------------
    170 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
    171     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     170forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T))
     171        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    172172T & join( T & this ) {
    173173        thread_dtor_guard_t guard = { this, defaultResumptionHandler };
  • libcfa/src/concurrency/thread.hfa

    rc715e5f rc3b9d639  
    8080};
    8181
    82 forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
    83     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     82forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T))
     83        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    8484void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) );
    8585void ^?{}( thread_dtor_guard_t & this );
     
    127127//----------
    128128// join
    129 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
    130     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     129forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T))
     130        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    131131T & join( T & this );
    132132
  • libcfa/src/exception.hfa

    rc715e5f rc3b9d639  
    1818// -----------------------------------------------------------------------------------------------
    1919
    20 // EHM_DEFAULT_VTABLE(exception_name, (arguments))
     20// EHM_DEFAULT_VTABLE(exception_type)
    2121// Create a declaration for a (possibly polymorphic) default vtable.
    22 #define EHM_DEFAULT_VTABLE(exception_name, arguments) \
    23         vtable(exception_name arguments) & const _default_vtable
     22// Mostly used by and for the currency module.
     23#define EHM_DEFAULT_VTABLE(type) vtable(type) & const _default_vtable
    2424
    25 // IS_EXCEPTION(exception_name [, (...parameters)])
    26 // IS_RESUMPTION_EXCEPTION(exception_name [, (parameters...)])
    27 // IS_TERMINATION_EXCEPTION(exception_name [, (parameters...)])
    28 // Create an assertion that exception_name, possibly with the qualifing parameters, is the given
    29 // kind of exception with the standard vtable with the same parameters if applicable.
    30 #define IS_EXCEPTION(...) _IS_EXCEPTION(is_exception, __VA_ARGS__, , ~)
    31 #define IS_RESUMPTION_EXCEPTION(...) _IS_EXCEPTION(is_resumption_exception, __VA_ARGS__, , ~)
    32 #define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~)
    33 #define _IS_EXCEPTION(kind, exception_name, parameters, ...) \
    34         kind(exception_name parameters, vtable(exception_name parameters))
     25// IS_EXCEPTION(exception_type)
     26// IS_RESUMPTION_EXCEPTION(exception_type)
     27// IS_TERMINATION_EXCEPTION(exception_type)
     28// Create an assertion that exception_type is the given kind of exception.
     29// This is used to mimic associated types so the vtable type is unmentioned.
     30#define IS_EXCEPTION(type) is_exception(type, vtable(type))
     31#define IS_RESUMPTION_EXCEPTION(type) is_resumption_exception(type, vtable(type))
     32#define IS_TERMINATION_EXCEPTION(type) is_termination_exception(type, vtable(type))
  • tests/exceptions/defaults.cfa

    rc715e5f rc3b9d639  
    77};
    88
     9// Manually define the virtual table and helper functions.
    910void copy(log_message * this, log_message * that) {
    1011        *this = *that;
Note: See TracChangeset for help on using the changeset viewer.