Changeset 1c01c58 for libcfa/src/concurrency/coroutine.hfa
- Timestamp:
- Sep 9, 2020, 5:03:40 PM (3 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b9fa85b, c402739
- Parents:
- 2b7f6f0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
r2b7f6f0 r1c01c58 18 18 #include <assert.h> 19 19 #include "invoke.h" 20 #include "../exception.hfa" 21 22 //----------------------------------------------------------------------------- 23 // Exception thrown from resume when a coroutine stack is cancelled. 24 // Should not have to be be sized (see trac #196). 25 FORALL_DATA_EXCEPTION(CoroutineCancelled, 26 (dtype coroutine_t | sized(coroutine_t)), (coroutine_t)) ( 27 coroutine_t * the_coroutine; 28 exception_t * the_exception; 29 ); 30 31 forall(dtype T) 32 void mark_exception(CoroutineCancelled(T) *); 33 34 forall(dtype T | sized(T)) 35 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src); 36 37 forall(dtype T) 38 const char * msg(CoroutineCancelled(T) *); 20 39 21 40 //----------------------------------------------------------------------------- … … 23 42 // Anything that implements this trait can be resumed. 24 43 // Anything that is resumed is a coroutine. 25 trait is_coroutine(dtype T) { 26 void main(T & this); 27 $coroutine * get_coroutine(T & this); 44 trait is_coroutine(dtype T | sized(T) 45 | is_resumption_exception(CoroutineCancelled(T)) 46 | VTABLE_ASSERTION(CoroutineCancelled, (T))) { 47 void main(T & this); 48 $coroutine * get_coroutine(T & this); 28 49 }; 29 50 … … 112 133 } 113 134 } 135 136 forall(dtype T | is_coroutine(T)) 137 void __cfaehm_cancelled_coroutine( T & cor, $coroutine * desc ); 114 138 115 139 // Resume implementation inlined for performance … … 145 169 // always done for performance testing 146 170 $ctx_switch( src, dst ); 171 if ( unlikely(dst->cancellation) ) { 172 __cfaehm_cancelled_coroutine( cor, dst ); 173 } 147 174 148 175 return cor;
Note: See TracChangeset
for help on using the changeset viewer.