Changeset 153dc387


Ignore:
Timestamp:
Jan 14, 2021, 2:32:36 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:
7223dbf2
Parents:
ee59ede
Message:

Main now print stats every 10 sec

File:
1 edited

Legend:

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

    ree59ede r153dc387  
    1111
    1212#include <kernel.hfa>
     13#include <iofwd.hfa>
    1314#include <stats.hfa>
    1415#include <time.hfa>
     
    4849extern void init_protocol(void);
    4950extern void deinit_protocol(void);
     51
     52//=============================================================================================
     53// Stats Printer
     54//============================================================================================='
     55
     56thread StatsPrinter {};
     57
     58void ?{}( StatsPrinter & this ) {
     59        ((thread&)this){ "Stats Printer Thread" };
     60}
     61
     62void main(StatsPrinter & this) {
     63        LOOP: for() {
     64                waitfor( ^?{} : this) {
     65                        break LOOP;
     66                }
     67                or else {}
     68
     69                sleep(10`s);
     70
     71                print_stats_now( *options.clopts.instance, CFA_STATS_READY_Q | CFA_STATS_IO );
     72        }
     73}
    5074
    5175//=============================================================================================
     
    128152                {
    129153                        ServerProc procs[options.clopts.nprocs];
     154                        StatsPrinter printer;
    130155
    131156                        init_protocol();
     
    152177                                        char buffer[128];
    153178                                        while(!feof(stdin)) {
    154                                                 fgets(buffer, 128, stdin);
     179                                                int ret = cfa_read(0, buffer, 128, 0, -1`s, 0p, 0p);
     180                                                if(ret < 0) abort( "main read error: (%d) %s\n", (int)errno, strerror(errno) );
    155181                                        }
    156182
     
    159185
    160186                                for(i; options.clopts.nworkers) {
    161                                         printf("Cancelling %p\n", (void*)workers[i].cancel.target);
    162187                                        workers[i].done = true;
    163188                                        cancel(workers[i].cancel);
Note: See TracChangeset for help on using the changeset viewer.