Changeset b583113 for libcfa/src
- Timestamp:
- Apr 21, 2021, 3:44:58 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 578c09a
- Parents:
- 7711064
- Location:
- libcfa/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
r7711064 rb583113 46 46 47 47 //----------------------------------------------------------------------------- 48 EHM_VIRTUAL_TABLE(SomeCoroutineCancelled, std_coroutine_cancelled);49 50 48 forall(T &) 51 49 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) { … … 62 60 // This code should not be inlined. It is the error path on resume. 63 61 forall(T & | is_coroutine(T)) 64 void __cfaehm_cancelled_coroutine( T & cor, $coroutine * desc ) { 62 void __cfaehm_cancelled_coroutine( 63 T & cor, $coroutine * desc, _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable ) { 65 64 verify( desc->cancellation ); 66 65 desc->state = Cancelled; … … 68 67 69 68 // TODO: Remove explitate vtable set once trac#186 is fixed. 70 SomeCoroutineCancelledexcept;71 except.virtual_table = & std_coroutine_cancelled;69 CoroutineCancelled(T) except; 70 except.virtual_table = &_default_vtable; 72 71 except.the_coroutine = &cor; 73 72 except.the_exception = except; 74 73 // Why does this need a cast? 75 throwResume ( SomeCoroutineCancelled&)except;74 throwResume (CoroutineCancelled(T) &)except; 76 75 77 76 except->virtual_table->free( except ); … … 146 145 // Part of the Public API 147 146 // Not inline since only ever called once per coroutine 148 forall(T & | is_coroutine(T) )147 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; }) 149 148 void prime(T& cor) { 150 149 $coroutine* this = get_coroutine(cor); -
libcfa/src/concurrency/coroutine.hfa
r7711064 rb583113 22 22 //----------------------------------------------------------------------------- 23 23 // Exception thrown from resume when a coroutine stack is cancelled. 24 EHM_EXCEPTION(SomeCoroutineCancelled)(25 void * the_coroutine;26 exception_t * the_exception;27 );28 29 EHM_EXTERN_VTABLE(SomeCoroutineCancelled, std_coroutine_cancelled);30 31 24 EHM_FORALL_EXCEPTION(CoroutineCancelled, (coroutine_t &), (coroutine_t)) ( 32 25 coroutine_t * the_coroutine; … … 44 37 // Anything that implements this trait can be resumed. 45 38 // Anything that is resumed is a coroutine. 46 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION( SomeCoroutineCancelled)) {39 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) { 47 40 void main(T & this); 48 41 $coroutine * get_coroutine(T & this); … … 67 60 //----------------------------------------------------------------------------- 68 61 // Public coroutine API 69 forall(T & | is_coroutine(T) )62 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; }) 70 63 void prime(T & cor); 71 64 … … 137 130 138 131 forall(T & | is_coroutine(T)) 139 void __cfaehm_cancelled_coroutine( T & cor, $coroutine * desc ); 132 void __cfaehm_cancelled_coroutine( 133 T & cor, $coroutine * desc, _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable ); 140 134 141 135 // Resume implementation inlined for performance 142 forall(T & | is_coroutine(T) )136 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; }) 143 137 static inline T & resume(T & cor) { 144 138 // optimization : read TLS once and reuse it … … 170 164 $ctx_switch( src, dst ); 171 165 if ( unlikely(dst->cancellation) ) { 172 __cfaehm_cancelled_coroutine( cor, dst );166 __cfaehm_cancelled_coroutine( cor, dst, _default_vtable ); 173 167 } 174 168 -
libcfa/src/exception.hfa
r7711064 rb583113 142 142 _EHM_VTABLE_TYPE(exception_name) parameters const &) {} \ 143 143 144 #define _EHM_TRAIT_FUNCTION2(exception_name, forall_clause, parameters) \145 forall_clause _EHM_VTABLE_TYPE(exception_name) parameters const & \146 get_exception_vtable(exception_name parameters const & this)147 148 144 #define __EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \ 149 145 forall_clause inline _EHM_VTABLE_TYPE(exception_name) parameters const & \
Note: See TracChangeset
for help on using the changeset viewer.