Changeset 0244ab6


Ignore:
Timestamp:
Jul 5, 2026, 11:32:02 PM (4 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6fbd475
Parents:
29e1582
Message:

elide warning message -Wdangling-pointer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrency/suspend_then.cfa

    r29e1582 r0244ab6  
    1919#endif
    2020
    21 #if !defined(TEST_FOREVER)
     21#if ! defined(TEST_FOREVER)
    2222        static inline void print(const char * const text ) {
    2323                write( STDOUT_FILENO, text, strlen(text) );
    2424        }
    2525#else
    26         static inline void print(Printer & this, const char * const text ) {}
     26        static inline void print( Printer & this, const char * const text ) {}
    2727#endif
    2828
     
    3333
    3434void store(Coroutine & cor) {
    35         __atomic_store_n(&the_cor, &cor, __ATOMIC_SEQ_CST);
     35        __atomic_store_n( &the_cor, &cor, __ATOMIC_SEQ_CST );
    3636}
    3737
    38 Coroutine * take(void) {
     38Coroutine * take( void ) {
    3939        Coroutine * val = 0p;
    40         Coroutine * ret = __atomic_exchange_n(&the_cor, val, __ATOMIC_SEQ_CST);
    41         assert(!ret || !the_cor);
     40        Coroutine * ret = __atomic_exchange_n( &the_cor, val, __ATOMIC_SEQ_CST );
     41        assert( ! ret || ! the_cor );
    4242        return ret;
    4343}
    4444
    45 void main(Coroutine& this) {
    46         this.i = 0;
     45void main( Coroutine & this ) with( this ) {
    4746        suspend;
    48         for(;TEST(this.i < N); this.i++) {
    49 
    50                 print("C - Suspending\n");
     47        for( i = 0; TEST( i < N ); i++ ) {
     48                print( "C - Suspending\n" );
    5149                suspend{
    52                         print("C - Publishing\n");
    53                         assert(!the_cor);
     50                        print( "C - Publishing\n" );
     51                        assert( ! the_cor );
    5452                        store( this );
    5553                }
    56                 assert(!the_cor);
    57                 print("C - Back\n");
     54                assert( ! the_cor );
     55                print( "C - Back\n" );
    5856                KICK_WATCHDOG;
    5957                yield();
     
    6664void main( Thread & ) {
    6765        Coroutine * mine = 0p;
    68         while(!done) {
     66        while ( ! done ) {
    6967                yield();
     68                mine = take();
     69                if ( ! mine ) continue;
    7070
    71                 mine = take();
    72                 if(!mine) continue;
    73 
    74                 print("T - took\n");
    75                 resume(*mine);
     71                print( "T - took\n" );
     72                resume( *mine );
    7673        }
    7774}
     
    8178        processor p[2];
    8279        Coroutine c;
    83         resume(c); // Prime the coroutine to avoid one of the threads being its starter
     80        resume( c ); // Prime the coroutine to avoid one of the threads being its starter
     81
     82        #pragma GCC diagnostic push
     83        #pragma GCC diagnostic ignored "-Wdangling-pointer"     // this assignment is ok
    8484        the_cor = &c;
     85        #pragma GCC diagnostic pop
     86
    8587        {
    8688                Thread t[2];
Note: See TracChangeset for help on using the changeset viewer.