Ignore:
Timestamp:
Jul 5, 2021, 4:44:20 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7f62b708
Parents:
ee23a8d
Message:

Step 1 of changing $thread to thread$

File:
1 edited

Legend:

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

    ree23a8d re84ab3d  
    3939trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
    4040        void main(T & this);
    41         $coroutine * get_coroutine(T & this);
     41        coroutine$ * get_coroutine(T & this);
    4242};
    4343
    44 #define DECL_COROUTINE(X) static inline $coroutine* get_coroutine(X& this) { return &this.__cor; } void main(X& this)
     44#define DECL_COROUTINE(X) static inline coroutine$* get_coroutine(X& this) { return &this.__cor; } void main(X& this)
    4545
    4646//-----------------------------------------------------------------------------
     
    4949// void ^?{}( coStack_t & this );
    5050
    51 void  ?{}( $coroutine & this, const char name[], void * storage, size_t storageSize );
    52 void ^?{}( $coroutine & this );
    53 
    54 static inline void ?{}( $coroutine & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
    55 static inline void ?{}( $coroutine & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
    56 static inline void ?{}( $coroutine & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
    57 static inline void ?{}( $coroutine & this, const char name[])                    { this{ name, 0p, 0 }; }
    58 static inline void ?{}( $coroutine & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }
     51void  ?{}( coroutine$ & this, const char name[], void * storage, size_t storageSize );
     52void ^?{}( coroutine$ & this );
     53
     54static inline void ?{}( coroutine$ & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
     55static inline void ?{}( coroutine$ & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
     56static inline void ?{}( coroutine$ & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
     57static inline void ?{}( coroutine$ & this, const char name[])                    { this{ name, 0p, 0 }; }
     58static inline void ?{}( coroutine$ & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }
    5959
    6060//-----------------------------------------------------------------------------
     
    6363void prime(T & cor);
    6464
    65 static inline struct $coroutine * active_coroutine() { return active_thread()->curr_cor; }
     65static inline struct coroutine$ * active_coroutine() { return active_thread()->curr_cor; }
    6666
    6767//-----------------------------------------------------------------------------
     
    7373
    7474        forall(T &)
    75         void __cfactx_start(void (*main)(T &), struct $coroutine * cor, T & this, void (*invoke)(void (*main)(void *), void *));
    76 
    77         extern void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct $coroutine *) __attribute__ ((__noreturn__));
     75        void __cfactx_start(void (*main)(T &), struct coroutine$ * cor, T & this, void (*invoke)(void (*main)(void *), void *));
     76
     77        extern void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine$ *) __attribute__ ((__noreturn__));
    7878
    7979        extern void __cfactx_switch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("__cfactx_switch");
     
    8282// Private wrappers for context switch and stack creation
    8383// Wrapper for co
    84 static inline void $ctx_switch( $coroutine * src, $coroutine * dst ) __attribute__((nonnull (1, 2))) {
     84static inline void $ctx_switch( coroutine$ * src, coroutine$ * dst ) __attribute__((nonnull (1, 2))) {
    8585        // set state of current coroutine to inactive
    8686        src->state = src->state == Halted ? Halted : Blocked;
    8787
    8888        // get the active thread once
    89         $thread * athrd = active_thread();
     89        thread$ * athrd = active_thread();
    9090
    9191        // Mark the coroutine
     
    124124                // will also migrate which means this value will
    125125                // stay in syn with the TLS
    126                 $coroutine * src = active_coroutine();
     126                coroutine$ * src = active_coroutine();
    127127
    128128                assertf( src->last != 0,
     
    141141forall(T & | is_coroutine(T))
    142142void __cfaehm_cancelled_coroutine(
    143         T & cor, $coroutine * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) );
     143        T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) );
    144144
    145145// Resume implementation inlined for performance
     
    151151        // will also migrate which means this value will
    152152        // stay in syn with the TLS
    153         $coroutine * src = active_coroutine();
    154         $coroutine * dst = get_coroutine(cor);
     153        coroutine$ * src = active_coroutine();
     154        coroutine$ * dst = get_coroutine(cor);
    155155
    156156        if( unlikely(dst->context.SP == 0p) ) {
     
    180180}
    181181
    182 static inline void resume( $coroutine * dst ) __attribute__((nonnull (1))) {
     182static inline void resume( coroutine$ * dst ) __attribute__((nonnull (1))) {
    183183        // optimization : read TLS once and reuse it
    184184        // Safety note: this is preemption safe since if
     
    186186        // will also migrate which means this value will
    187187        // stay in syn with the TLS
    188         $coroutine * src = active_coroutine();
     188        coroutine$ * src = active_coroutine();
    189189
    190190        // not resuming self ?
Note: See TracChangeset for help on using the changeset viewer.