Ignore:
Timestamp:
May 11, 2020, 1:53:29 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
504a7dc
Parents:
b7d6a36 (diff), a7b486b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into relaxed_ready

File:
1 moved

Legend:

Unmodified
Added
Removed
  • tests/concurrent/suspend_then.cfa

    rb7d6a36 r6a490b2  
    11#include <fstream.hfa>
    22#include <kernel.hfa>
    3 #include <monitor.hfa>
    43#include <thread.hfa>
    54#include <time.hfa>
     
    109#include "long_tests.hfa"
    1110
    12 #ifndef PREEMPTION_RATE
    13 #define PREEMPTION_RATE 10`ms
    14 #endif
    15 
    1611Duration default_preemption() {
    17         return PREEMPTION_RATE;
     12        return 0;
    1813}
    1914
     
    2621#if !defined(TEST_FOREVER)
    2722        static inline void print(const char * const text ) {
    28                 write( STDERR_FILENO, text, strlen(text) );
     23                write( STDOUT_FILENO, text, strlen(text) );
    2924        }
    3025#else
     
    3227#endif
    3328
    34 coroutine Coroutine {};
     29generator Coroutine { int i; };
    3530
    3631volatile bool done = false;
     
    4944
    5045void main(Coroutine& this) {
    51         suspend();
    52         for(int i = 0; TEST(i < N); i++) {
     46        this.i = 0;
     47        suspend;
     48        for(;TEST(this.i < N); this.i++) {
    5349
    54                 print("C - Suspending");
    55                 void publish() {
    56                         print("C - Publishing");
     50                print("C - Suspending\n");
     51                suspend{
     52                        print("C - Publishing\n");
    5753                        assert(!the_cor);
    5854                        store( this );
    5955                }
    60                 suspend_then(publish);
    6156                assert(!the_cor);
    62                 print("Coroutine 2");
     57                print("C - Back\n");
    6358                KICK_WATCHDOG;
    6459                yield();
    6560        }
    6661        done = true;
    67         suspend();
     62        suspend;
    6863}
    6964
     
    7772                if(!mine) continue;
    7873
    79                 print("T - took");
     74                print("T - took\n");
    8075                resume(*mine);
    81                 print("T - back");
    8276        }
    8377}
Note: See TracChangeset for help on using the changeset viewer.