Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/cofor.cfa

    ree9ad40 re4c3819  
    44// cofor ( uC++ COFOR )
    55
    6 thread cofor_runner {
     6thread co_runner {
    77        ssize_t low, high;
    88        __cofor_body_t loop_body;
    99};
    1010
    11 static void ?{}( cofor_runner & this, ssize_t low, ssize_t high, __cofor_body_t loop_body ) {
     11static void ?{}( co_runner & this, ssize_t low, ssize_t high, __cofor_body_t loop_body ) {
    1212        this.low = low;
    1313        this.high = high;
     
    1515}
    1616
    17 void main( cofor_runner & this ) with( this ) {
     17void main( co_runner & this ) with( this ) {
    1818        for ( ssize_t i = low; i < high; i++ )
    1919                loop_body(i);
    2020}
    2121
    22 void __Cofor__( ssize_t low, ssize_t high, __cofor_body_t loop_body ) libcfa_public {
     22void cofor( ssize_t low, ssize_t high, __cofor_body_t loop_body ) libcfa_public {
    2323        ssize_t range = high - low;
    2424  if ( range <= 0 ) return;
     
    2929        ssize_t i = 0;
    3030        ssize_t stride_iter = low;
    31         cofor_runner * runners[ threads ];
     31        co_runner * runners[ threads ];
    3232        for ( i; threads ) {
    3333                runners[i] = alloc();
     
    4545}
    4646
     47//////////////////////////////////////////////////////////////////////////////////////////
     48// parallel (COBEGIN/COEND)
    4749
     50thread para_runner {
     51        parallel_stmt_t body;
     52        void * arg;
     53};
     54
     55static void ?{}( para_runner & this, parallel_stmt_t body, void * arg ) {
     56        this.body = body;
     57        this.arg = arg;
     58}
     59
     60void main( para_runner & this ) with( this ) { body( arg ); }
     61
     62void parallel( parallel_stmt_t * stmts, void ** args, size_t num ) libcfa_public {
     63        para_runner * runners[ num ];
     64        for ( i; num )
     65                (*(runners[i] = malloc())){ stmts[i], args[i] };
     66        for ( i; num )
     67                delete( runners[i] );
     68}
     69
Note: See TracChangeset for help on using the changeset viewer.