Ignore:
Timestamp:
Mar 2, 2021, 1:59:38 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d5006b1
Parents:
dddb3dd0
Message:

update http server according to last push

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/main.cfa

    rdddb3dd0 r2cd784a  
    3838}
    3939
     40void ^?{}( StatsPrinter & mutex this ) {}
     41
    4042void main(StatsPrinter & this) {
    4143        LOOP: for() {
     
    5456// Globals
    5557//=============================================================================================
    56 // struct ServerProc {
    57 //      processor self;
    58 // };
    59 
    60 // void ?{}( ServerProc & this ) {
    61 //      /* paranoid */ assert( options.clopts.instance != 0p );
    62 //      (this.self){ "Benchmark Processor", *options.clopts.instance };
    63 
    64 //      #if !defined(__CFA_NO_STATISTICS__)
    65 //              if( options.clopts.procstats ) {
    66 //                      print_stats_at_exit( this.self, options.clopts.instance->print_stats );
    67 //              }
    68 //              if( options.clopts.viewhalts ) {
    69 //                      print_halts( this.self );
    70 //              }
    71 //      #endif
    72 // }
    73 
    74 // struct ServerIoContext {
    75 //      io_context self;
    76 // };
    77 
    78 // void ?{}( ServerIoContext & this ) {
    79 //      /* paranoid */ assert( options.clopts.instance != 0p );
    80 //      (this.self){ *options.clopts.instance };
    81 // }
    82 
    8358struct ServerCluster {
    8459        cluster self;
    8560        processor    * procs;
    86         io_context   * ctxs;
     61        // io_context   * ctxs;
    8762        StatsPrinter * prnt;
    8863
     
    10681        }
    10782
    108         this.ctxs = alloc(options.clopts.nprocs);
    109         for(i; options.clopts.nprocs) {
    110                 (this.ctxs[i]){ this.self };
    111         }
    112 
    113         this.prnt = alloc(options.clopts.nprocs);
    114         for(i; options.clopts.nprocs) {
    115                 (this.prnt[i]){ this.self };
     83        if(options.stats) {
     84                this.prnt = alloc();
     85                (*this.prnt){ this.self };
     86        } else {
     87                this.prnt = 0p;
    11688        }
    11789
     
    12597
    12698void ^?{}( ServerCluster & this ) {
    127         for(i; options.clopts.nprocs) {
    128                 ^(this.prnt[i]){};
    129         }
    130         free(this.prnt);
    131 
    132         for(i; options.clopts.nprocs) {
    133                 ^(this.ctxs[i]){};
    134         }
    135         free(this.ctxs);
     99        delete(this.prnt);
    136100
    137101        for(i; options.clopts.nprocs) {
     
    250214                                {
    251215                                        char buffer[128];
    252                                         while(int ret = cfa_read(0, buffer, 128, 0); ret != 0) {
     216                                        for() {
     217                                                int ret = cfa_read(0, buffer, 128, 0);
     218                                                if(ret == 0) break;
    253219                                                if(ret < 0) abort( "main read error: (%d) %s\n", (int)errno, strerror(errno) );
     220                                                sout | "User wrote '" | "" | nonl;
     221                                                write(sout, buffer, ret - 1);
     222                                                sout | "'";
    254223                                        }
    255224
Note: See TracChangeset for help on using the changeset viewer.