Changeset c3b9d639
- Timestamp:
- May 26, 2022, 10:21:17 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 5416b44
- Parents:
- c715e5f
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
rc715e5f rc3b9d639 62 62 forall(T & | is_coroutine(T)) 63 63 void __cfaehm_cancelled_coroutine( 64 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled ,(T)) ) libcfa_public {64 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) ) libcfa_public { 65 65 verify( desc->cancellation ); 66 66 desc->state = Cancelled; … … 146 146 // Part of the Public API 147 147 // Not inline since only ever called once per coroutine 148 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled ,(T)); })148 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); }) 149 149 void prime(T& cor) libcfa_public { 150 150 coroutine$* this = get_coroutine(cor); -
libcfa/src/concurrency/coroutine.hfa
rc715e5f rc3b9d639 38 38 // Anything that implements this trait can be resumed. 39 39 // Anything that is resumed is a coroutine. 40 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled ,(T))) {40 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) { 41 41 void main(T & this); 42 42 coroutine$ * get_coroutine(T & this); … … 61 61 //----------------------------------------------------------------------------- 62 62 // Public coroutine API 63 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled ,(T)); })63 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); }) 64 64 void prime(T & cor); 65 65 … … 140 140 forall(T & | is_coroutine(T)) 141 141 void __cfaehm_cancelled_coroutine( 142 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled ,(T)) );142 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) ); 143 143 144 144 // Resume implementation inlined for performance 145 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled ,(T)); })145 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); }) 146 146 static inline T & resume(T & cor) { 147 147 // optimization : read TLS once and reuse it -
libcfa/src/concurrency/thread.cfa
rc715e5f rc3b9d639 89 89 } 90 90 91 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled ,(T))92 | { EHM_DEFAULT_VTABLE(ThreadCancelled ,(T)); })91 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T)) 92 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 93 93 void ?{}( thread_dtor_guard_t & this, 94 94 T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) { … … 168 168 169 169 //----------------------------------------------------------------------------- 170 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled ,(T))171 | { EHM_DEFAULT_VTABLE(ThreadCancelled,(T)); })170 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T)) 171 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 172 172 T & join( T & this ) { 173 173 thread_dtor_guard_t guard = { this, defaultResumptionHandler }; -
libcfa/src/concurrency/thread.hfa
rc715e5f rc3b9d639 80 80 }; 81 81 82 forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled ,(T))83 | { EHM_DEFAULT_VTABLE(ThreadCancelled,(T)); })82 forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T)) 83 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 84 84 void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) ); 85 85 void ^?{}( thread_dtor_guard_t & this ); … … 127 127 //---------- 128 128 // join 129 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled ,(T))130 | { EHM_DEFAULT_VTABLE(ThreadCancelled,(T)); })129 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T)) 130 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 131 131 T & join( T & this ); 132 132 -
libcfa/src/exception.hfa
rc715e5f rc3b9d639 18 18 // ----------------------------------------------------------------------------------------------- 19 19 20 // EHM_DEFAULT_VTABLE(exception_ name, (arguments))20 // EHM_DEFAULT_VTABLE(exception_type) 21 21 // Create a declaration for a (possibly polymorphic) default vtable. 22 #define EHM_DEFAULT_VTABLE(exception_name, arguments) \ 23 vtable(exception_name arguments) & const _default_vtable22 // Mostly used by and for the currency module. 23 #define EHM_DEFAULT_VTABLE(type) vtable(type) & const _default_vtable 24 24 25 // IS_EXCEPTION(exception_name [, (...parameters)]) 26 // IS_RESUMPTION_EXCEPTION(exception_name [, (parameters...)]) 27 // IS_TERMINATION_EXCEPTION(exception_name [, (parameters...)]) 28 // Create an assertion that exception_name, possibly with the qualifing parameters, is the given 29 // kind of exception with the standard vtable with the same parameters if applicable. 30 #define IS_EXCEPTION(...) _IS_EXCEPTION(is_exception, __VA_ARGS__, , ~) 31 #define IS_RESUMPTION_EXCEPTION(...) _IS_EXCEPTION(is_resumption_exception, __VA_ARGS__, , ~) 32 #define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~) 33 #define _IS_EXCEPTION(kind, exception_name, parameters, ...) \ 34 kind(exception_name parameters, vtable(exception_name parameters)) 25 // IS_EXCEPTION(exception_type) 26 // IS_RESUMPTION_EXCEPTION(exception_type) 27 // IS_TERMINATION_EXCEPTION(exception_type) 28 // Create an assertion that exception_type is the given kind of exception. 29 // This is used to mimic associated types so the vtable type is unmentioned. 30 #define IS_EXCEPTION(type) is_exception(type, vtable(type)) 31 #define IS_RESUMPTION_EXCEPTION(type) is_resumption_exception(type, vtable(type)) 32 #define IS_TERMINATION_EXCEPTION(type) is_termination_exception(type, vtable(type)) -
tests/exceptions/defaults.cfa
rc715e5f rc3b9d639 7 7 }; 8 8 9 // Manually define the virtual table and helper functions. 9 10 void copy(log_message * this, log_message * that) { 10 11 *this = *that;
Note: See TracChangeset
for help on using the changeset viewer.