Ignore:
Timestamp:
Sep 17, 2023, 10:17:50 PM (10 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
a2c2363
Parents:
50be8af
Message:

formatting, replace constructor calls with set_allocation calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrency/actors/executor.cfa

    r50be8af r7edf912  
    1010static int ids = 0;
    1111struct d_actor {
    12     inline actor;
    13     d_actor * gstart;
    14     int id, rounds, recs, sends;
     12        inline actor;
     13        d_actor * gstart;
     14        int id, rounds, recs, sends;
    1515};
    1616void ?{}( d_actor & this ) with(this) {
    17     id = ids++;
    18     gstart = (&this + (id / Set * Set - id)); // remember group-start array-element
    19     rounds = Set * Rounds;      // send at least one message to each group member
    20     recs = 0;
    21     sends = 0;
     17        id = ids++;
     18        gstart = (&this + (id / Set * Set - id)); // remember group-start array-element
     19        rounds = Set * Rounds;  // send at least one message to each group member
     20        recs = 0;
     21        sends = 0;
    2222}
    2323
     
    2525
    2626allocation receive( d_actor & this, d_msg & msg ) with( this ) {
    27     if ( recs == rounds ) return Finished;
    28     if ( recs % Batch == 0 ) {
    29         for ( i; Batch ) {
    30             gstart[sends % Set] | shared_msg;
    31             sends += 1;
    32         }
    33     }
    34     recs += 1;
    35     return Nodelete;
     27        if ( recs == rounds ) return Finished;
     28        if ( recs % Batch == 0 ) {
     29                for ( i; Batch ) {
     30                        gstart[sends % Set] | shared_msg;
     31                        sends += 1;
     32                }
     33        }
     34        recs += 1;
     35        return Nodelete;
    3636}
    3737
    3838int main( int argc, char * argv[] ) {
    39     switch ( argc ) {
     39        switch ( argc ) {
    4040          case 7:
    4141                if ( strcmp( argv[6], "d" ) != 0 ) {                    // default ?
     
    7272          default:
    7373                exit | "Usage: " | argv[0]
    74             | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors
     74                        | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors
    7575                         | ") ] [ set (> 0) | 'd' (default " | Set
    7676                         | ") ] [ rounds (> 0) | 'd' (default " | Rounds
     
    8181        } // switch
    8282
    83     executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true };
     83        executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true };
    8484
    85     sout | "starting";
     85        sout | "starting";
    8686
    87     start_actor_system( e );
     87        start_actor_system( e );
    8888
    89     sout | "started";
     89        sout | "started";
    9090
    91     d_actor actors[ Actors ];
     91        d_actor actors[ Actors ];
    9292
    9393        for ( i; Actors ) {
     
    9595        } // for
    9696
    97     sout | "stopping";
     97        sout | "stopping";
    9898
    99     stop_actor_system();
     99        stop_actor_system();
    100100
    101     sout | "stopped";
    102 
    103     return 0;
     101        sout | "stopped";
    104102}
Note: See TracChangeset for help on using the changeset viewer.