- File:
-
- 1 edited
-
libcfa/src/concurrency/coroutine.hfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
r3c06bba r212c2187 64 64 forall(dtype T | is_coroutine(T)) 65 65 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");72 66 } 73 67 74 68 // 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 */); 69 extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 70 extern void create_stack( coStack_t * this, unsigned int storageSize ); 97 71 98 72 // Suspend implementation inlined for performance … … 128 102 coroutine_desc * dst = get_coroutine(cor); 129 103 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); 132 106 CtxStart(&cor, CtxInvokeCoroutine); 133 107 }
Note:
See TracChangeset
for help on using the changeset viewer.