Ignore:
File:
1 edited

Legend:

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

    r3c06bba r212c2187  
    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");
    7266}
    7367
    7468// Private wrappers for context switch and stack creation
    75 // Wrapper for co
    76 static 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 
    96 extern void __stack_prepare   ( __stack_info_t * this, size_t size /* ignored if storage already allocated */);
     69extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
     70extern void create_stack( coStack_t * this, unsigned int storageSize );
    9771
    9872// Suspend implementation inlined for performance
     
    128102        coroutine_desc * dst = get_coroutine(cor);
    129103
    130         if( unlikely(dst->context.SP == NULL) ) {
    131                 __stack_prepare(&dst->stack, 65000);
     104        if( unlikely(!dst->stack.base) ) {
     105                create_stack(&dst->stack, dst->stack.size);
    132106                CtxStart(&cor, CtxInvokeCoroutine);
    133107        }
Note: See TracChangeset for help on using the changeset viewer.