Changes in / [42cd67b8:fd3be42]


Ignore:
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified libcfa/src/concurrency/select.cfa

    r42cd67b8 rfd3be42  
    1010// Author           : Colby Alexander Parsons
    1111// Created On       : Thu Apr 21 19:46:50 2023
    12 // Last Modified By :
    13 // Last Modified On :
    14 // Update Count     :
     12// Last Modified By : Kyoung Seo
     13// Last Modified On : Wed Mar 19 12:00:00 2025
     14// Update Count     : 1
    1515//
    1616
     
    5151bool on_selected( select_timeout_node & this, select_node & node ) { return true; }
    5252
    53 // Gateway routine to wait on duration
    54 select_timeout_node timeout( Duration duration ) {
    55         select_timeout_node node{ duration, timeout_handler_select_cast };
    56     return node;
    57 }
    58 select_timeout_node sleep( Duration duration ) { return timeout( duration ); }
    59 
  • TabularUnified libcfa/src/concurrency/select.hfa

    r42cd67b8 rfd3be42  
    1010// Author           : Colby Alexander Parsons
    1111// Created On       : Thu Jan 21 19:46:50 2023
    12 // Last Modified By :
    13 // Last Modified On :
    14 // Update Count     :
     12// Last Modified By : Kyoung Seo
     13// Last Modified On : Wed Mar 19 12:00:00 2025
     14// Update Count     : 1
    1515//
    1616
     
    214214select_timeout_node __CFA_select_get_type( select_timeout_node this );
    215215
    216 // Gateway routines to waituntil on duration
    217 select_timeout_node timeout( Duration duration );
    218 select_timeout_node sleep( Duration duration );
    219 
     216// Timer macro for waituntil
     217#define _timeout(D) (select_timeout_node) { D, timeout_handler_select_cast }
  • TabularUnified tests/concurrency/waituntil/all_types.cfa

    r42cd67b8 rfd3be42  
    3939        or when( i % 4 < 2 ) waituntil( B ) { consume_b_val( myTotal ); }
    4040        or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; }
    41         or when( i % 3 ) waituntil( timeout( 1`ms ) ) {}
     41        or when( i % 3 ) waituntil( _timeout( 1`ms ) ) {}
    4242        or when( i % 8 < 4 ) else {}
    4343    }
     
    5353        or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; }
    5454        or waituntil( B ) { consume_b_val( myTotal ); }
    55         or waituntil( timeout( 100`ns ) ) { }
     55        or waituntil( _timeout( 100`ns ) ) { }
    5656    }
    5757    __atomic_fetch_add( &globalTotal, myTotal, __ATOMIC_SEQ_CST );
     
    9999                or when( j % 4 < 2 ) waituntil( B ) { produce_b_val( total ); }
    100100                and when( j % 8 < 4 ) waituntil( C << j ) { total += j; }
    101                 and waituntil( timeout( 1`ns ) ) {}
     101                and waituntil( _timeout( 1`ns ) ) {}
    102102                if ( j == numtimes / 2 )
    103103                    fulfil( F, val_to_deliver );
  • TabularUnified tests/concurrency/waituntil/timeout.cfa

    r42cd67b8 rfd3be42  
    66
    77int main() {
    8     waituntil( sleep( 1`ms ) ) { printf("timeout\n"); }
    9     waituntil( timeout( 1`s ) ) { printf("timeout\n"); } or waituntil( timeout( 2`s ) ) { printf("timeout\n"); }
    10     waituntil( timeout( 100`s ) ) { printf("timeout 1\n"); } or else { printf("else\n"); }
    11     waituntil( timeout( 1`ns ) ) { printf("timeout\n"); } and waituntil( timeout( 2`s ) ) { printf("timeout\n"); }
     8    waituntil( _timeout( 1`ms ) ) { printf("timeout\n"); }
     9    waituntil( _timeout( 1`s ) ) { printf("timeout\n"); } or waituntil( _timeout( 2`s ) ) { printf("timeout\n"); }
     10    waituntil( _timeout( 100`s ) ) { printf("timeout 1\n"); } or else { printf("else\n"); }
     11    waituntil( _timeout( 1`ns ) ) { printf("timeout\n"); } and waituntil( _timeout( 2`s ) ) { printf("timeout\n"); }
    1212    int count = 0;
    1313    for ( i; 1000 )
    14         waituntil( timeout( 1`ns ) ) { count++; } or else { count++; }
     14        waituntil( _timeout( 1`ns ) ) { count++; } or else { count++; }
    1515
    1616    assert( count == 1000 );
    17     sleep( 1`ms );
     17    _timeout( 1`ms );
    1818    printf("done\n");
    1919}
Note: See TracChangeset for help on using the changeset viewer.