Ignore:
Timestamp:
Sep 17, 2023, 11:19:08 AM (13 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7edf912
Parents:
697c957
Message:

clean up command-line handling and I/O

File:
1 edited

Legend:

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

    r697c957 r50be8af  
    4040          case 7:
    4141                if ( strcmp( argv[6], "d" ) != 0 ) {                    // default ?
    42                         BufSize = atoi( argv[6] );
    43                         if ( BufSize < 0 ) goto Usage;
     42                        BufSize = ato( argv[6] );
     43                        if ( BufSize < 0 ) fallthru default;
    4444                } // if
    4545          case 6:
    4646                if ( strcmp( argv[5], "d" ) != 0 ) {                    // default ?
    47                         Batch = atoi( argv[5] );
    48                         if ( Batch < 1 ) goto Usage;
     47                        Batch = ato( argv[5] );
     48                        if ( Batch < 1 ) fallthru default;
    4949                } // if
    5050          case 5:
    5151                if ( strcmp( argv[4], "d" ) != 0 ) {                    // default ?
    52                         Processors = atoi( argv[4] );
    53                         if ( Processors < 1 ) goto Usage;
     52                        Processors = ato( argv[4] );
     53                        if ( Processors < 1 ) fallthru default;
    5454                } // if
    5555          case 4:
    5656                if ( strcmp( argv[3], "d" ) != 0 ) {                    // default ?
    57                         Rounds = atoi( argv[3] );
    58                         if ( Rounds < 1 ) goto Usage;
     57                        Rounds = ato( argv[3] );
     58                        if ( Rounds < 1 ) fallthru default;
    5959                } // if
    6060          case 3:
    6161                if ( strcmp( argv[2], "d" ) != 0 ) {                    // default ?
    62                         Set = atoi( argv[2] );
    63                         if ( Set < 1 ) goto Usage;
     62                        Set = ato( argv[2] );
     63                        if ( Set < 1 ) fallthru default;
    6464                } // if
    6565          case 2:
    6666                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
    67                         Actors = atoi( argv[1] );
    68                         if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) goto Usage;
     67                        Actors = ato( argv[1] );
     68                        if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) fallthru default;
    6969                } // if
    7070          case 1:                                                                                       // use defaults
    7171                break;
    7272          default:
    73           Usage:
    74                 sout | "Usage: " | argv[0]
     73                exit | "Usage: " | argv[0]
    7574             | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors
    7675                         | ") ] [ set (> 0) | 'd' (default " | Set
     
    8079                         | ") ] [ buffer size (>= 0) | 'd' (default " | BufSize
    8180                         | ") ]" ;
    82                 exit( EXIT_FAILURE );
    8381        } // switch
    8482
    8583    executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true };
    8684
    87     printf("starting\n");
     85    sout | "starting";
    8886
    8987    start_actor_system( e );
    9088
    91     printf("started\n");
     89    sout | "started";
    9290
    9391    d_actor actors[ Actors ];
     
    9795        } // for
    9896
    99     printf("stopping\n");
     97    sout | "stopping";
    10098
    10199    stop_actor_system();
    102100
    103     printf("stopped\n");
     101    sout | "stopped";
    104102
    105103    return 0;
Note: See TracChangeset for help on using the changeset viewer.