#include ////////////////////////////////////////////////////////////////////////////////////////// // cofor ( uC++ COFOR ) typedef void (*__cofor_body_t)( ssize_t ); void __Cofor__( ssize_t low, ssize_t high, __cofor_body_t loop_body ); #define COFOR( lidname, low, high, loopbody ) \ { \ void __CFA_loopLambda__( ssize_t lidname ) { \ loopbody \ } \ __Cofor__( low, high, __CFA_loopLambda__ ); \ } ////////////////////////////////////////////////////////////////////////////////////////// // corun // typedef void (*__CFA_corun_lambda_t)( void ); // used to run a corun statement in parallel thread co_runner { __CFA_corun_lambda_t body; }; // wraps a co_runner to provide RAII deallocation struct runner_block { co_runner * runner; }; static inline void ?{}( co_runner & this, __CFA_corun_lambda_t body ) { this.body = body; } void main( co_runner & this ) with( this ) { body(); } static inline void ?{}( runner_block & this ) {} static inline void ?{}( runner_block & this, __CFA_corun_lambda_t body ) { (*(this.runner = malloc())){ body }; } static inline void ^?{}( runner_block & this ) { delete( this.runner ); }