Changeset 680137a


Ignore:
Timestamp:
Sep 2, 2022, 12:23:54 PM (20 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
2284d20
Parents:
e228f46
Message:

Fixed indentation

Location:
tests/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/io/comp_basic.cfa

    re228f46 r680137a  
    2727
    2828struct {
    29       barrier & bar;
    30       int pipe[2];
     29        barrier & bar;
     30        int pipe[2];
    3131
    3232} globals;
     
    4545thread Reader {};
    4646void main(Reader & this) {
    47       bool do_read = has_user_level_blocking( (fptr_t)async_read );
     47        bool do_read = has_user_level_blocking( (fptr_t)async_read );
    4848
    49       for(TIMES) {
    50             io_future_t f;
    51             if ( do_read ) {
    52                   char thrash[1];
    53                   async_read(f, globals.pipe[0], thrash, 1, 0);
    54             } else {
    55                   fulfil(f, 0); // If we don't have user-level blocking just play along
    56             }
     49        for(TIMES) {
     50                io_future_t f;
     51                if ( do_read ) {
     52                        char thrash[1];
     53                        async_read(f, globals.pipe[0], thrash, 1, 0);
     54                } else {
     55                        fulfil(f, 0); // If we don't have user-level blocking just play along
     56                }
    5757
    58             block( globals.bar );
     58                block( globals.bar );
    5959
    6060                yield( prng( this, 15 ) );
    6161
    62             unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
     62                unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    6363                if(0 == (i % 100)) sout | i;
    6464
    65             wait( f );
     65                wait( f );
    6666
    67             if(f.result < 0)
    68                   abort | "Read error" | -f.result | ":" | strerror(-f.result);
     67                if(f.result < 0)
     68                        abort | "Read error" | -f.result | ":" | strerror(-f.result);
    6969
    70             block( globals.bar );
    71       }
     70                block( globals.bar );
     71        }
    7272}
    7373
     
    7777thread Writer {};
    7878void main(Writer & this) {
    79       for(TIMES) {
    80             block( globals.bar );
     79        for(TIMES) {
     80                block( globals.bar );
    8181
    82             sleep( 1`us );
     82                sleep( 1`us );
    8383
    84             char buf[1] = { '+' };
    85             int ret = write( globals.pipe[1], buf, 1 );
    86             if(ret < 0)
    87                   abort | "Write error" | errno | ":" | strerror(errno);
     84                char buf[1] = { '+' };
     85                int ret = write( globals.pipe[1], buf, 1 );
     86                if(ret < 0)
     87                        abort | "Write error" | errno | ":" | strerror(errno);
    8888
    89             block( globals.bar );
    90       }
     89                block( globals.bar );
     90        }
    9191}
    9292
    9393int main() {
    94       barrier bar = { 2 };
    95       &globals.bar = &bar;
    96       int ret = pipe(globals.pipe);
    97       if(ret != 0)
    98             abort | "Pipe error" | errno | ":" | strerror(errno);
     94        barrier bar = { 2 };
     95        &globals.bar = &bar;
     96        int ret = pipe(globals.pipe);
     97        if(ret != 0)
     98                abort | "Pipe error" | errno | ":" | strerror(errno);
    9999
    100100        sout | "starting";
    101101        {
    102102                Reader ior;
    103             Writer iow;
     103                Writer iow;
    104104        }
    105105        sout | "done";
  • tests/io/comp_fair.cfa

    re228f46 r680137a  
    2727
    2828struct {
    29       barrier & bar;
    30       int pipe[2];
     29        barrier & bar;
     30        int pipe[2];
    3131
    3232} globals;
     
    6565thread Reader {};
    6666void main(Reader & this) {
    67       bool do_read = has_user_level_blocking( (fptr_t)async_read );
     67        bool do_read = has_user_level_blocking( (fptr_t)async_read );
    6868
    69       for(TIMES) {
    70             io_future_t f;
    71             if ( do_read ) {
    72                   char thrash[1];
    73                   async_read(f, globals.pipe[0], thrash, 1, 0);
    74             } else {
    75                   fulfil(f, 0); // If we don't have user-level blocking just play along
    76             }
     69        for(TIMES) {
     70                io_future_t f;
     71                if ( do_read ) {
     72                        char thrash[1];
     73                        async_read(f, globals.pipe[0], thrash, 1, 0);
     74                } else {
     75                        fulfil(f, 0); // If we don't have user-level blocking just play along
     76                }
    7777
    78             block( globals.bar );
     78                block( globals.bar );
    7979
    8080                yield( prng( this, 15 ) );
    8181
    82             unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
     82                unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    8383                if(0 == (i % 100)) sout | i;
    8484
    85             wait( f );
     85                wait( f );
    8686
    87             if(f.result < 0)
    88                   abort | "Read error" | -f.result | ":" | strerror(-f.result);
     87                if(f.result < 0)
     88                        abort | "Read error" | -f.result | ":" | strerror(-f.result);
    8989
    90             block( globals.bar );
    91       }
     90                block( globals.bar );
     91        }
    9292}
    9393
     
    9797thread Writer {};
    9898void main(Writer & this) {
    99       for(TIMES) {
    100             block( globals.bar );
     99        for(TIMES) {
     100                block( globals.bar );
    101101
    102             sleep( 1`us );
     102                sleep( 1`us );
    103103
    104             char buf[1] = { '+' };
    105             int ret = write( globals.pipe[1], buf, 1 );
    106             if(ret < 0)
    107                   abort | "Write error" | errno | ":" | strerror(errno);
     104                char buf[1] = { '+' };
     105                int ret = write( globals.pipe[1], buf, 1 );
     106                if(ret < 0)
     107                        abort | "Write error" | errno | ":" | strerror(errno);
    108108
    109             block( globals.bar );
    110       }
     109                block( globals.bar );
     110        }
    111111}
    112112
     
    122122
    123123int main() {
    124       barrier bar = { 2 };
    125       &globals.bar = &bar;
    126       int ret = pipe(globals.pipe);
    127       if(ret != 0)
    128             abort | "Pipe error" | errno | ":" | strerror(errno);
     124        barrier bar = { 2 };
     125        &globals.bar = &bar;
     126        int ret = pipe(globals.pipe);
     127        if(ret != 0)
     128                abort | "Pipe error" | errno | ":" | strerror(errno);
    129129
    130130        processor p;
     
    134134                Spinner s;
    135135                Reader ior;
    136             Writer iow;
     136                Writer iow;
    137137        }
    138138        sout | "done";
Note: See TracChangeset for help on using the changeset viewer.