Ignore:
Timestamp:
Apr 15, 2019, 4:06:40 PM (3 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
deca0f5
Parents:
5c1a531
Message:

Inlined coroutine context switch routine

File:
1 edited

Legend:

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

    r5c1a531 r3c06bba  
    6464      forall(dtype T | is_coroutine(T))
    6565      void CtxStart(T * this, void ( *invoke)(T *));
     66
     67        extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     68
     69        extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch");
     70        // void CtxStore ( void * this ) asm ("CtxStore");
     71        // void CtxRet   ( void * dst  ) asm ("CtxRet");
    6672}
    6773
    6874// Private wrappers for context switch and stack creation
    69 extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
     75// Wrapper for co
     76static inline void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
     77        // set state of current coroutine to inactive
     78        src->state = src->state == Halted ? Halted : Inactive;
     79
     80        // set new coroutine that task is executing
     81        TL_GET( this_thread )->curr_cor = dst;
     82
     83        // context switch to specified coroutine
     84        verify( dst->context.SP );
     85        CtxSwitch( &src->context, &dst->context );
     86        // when CtxSwitch returns we are back in the src coroutine
     87
     88        // set state of new coroutine to active
     89        src->state = Active;
     90
     91        if( unlikely(src->cancellation != NULL) ) {
     92                _CtxCoroutine_Unwind(src->cancellation, src);
     93        }
     94}
     95
    7096extern void __stack_prepare   ( __stack_info_t * this, size_t size /* ignored if storage already allocated */);
    7197
Note: See TracChangeset for help on using the changeset viewer.