Changeset f019069 for tests/concurrent


Ignore:
Timestamp:
May 6, 2019, 10:09:02 AM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
63364d8
Parents:
b9696a8
Message:

Some more work on suspend_then

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/coroutineThen.cfa

    rb9696a8 rf019069  
    11#include <fstream.hfa>
    22#include <kernel.hfa>
     3#include <monitor.hfa>
     4#include <thread.hfa>
     5#include <time.hfa>
    36#include <stdlib.hfa>
    4 #include <thread.hfa>
    5 #include <monitor.hfa>
    6 #include <time.hfa>
     7#include <string.h>
    78
    89#define __kick_rate 150000ul
     
    2324#endif
    2425
    25 monitor Printer {};
    2626#if !defined(TEST_FOREVER)
    27         static inline void print(Printer & mutex this, const char * const text ) {
    28                 sout | text;
    29         }
    30 
    31         static inline void print(Printer & mutex this, const char * const text, int i ) {
    32                 sout | text | i;
     27        static inline void print(const char * const text ) {
     28                write( STDERR_FILENO, text, strlen(text) );
    3329        }
    3430#else
    3531        static inline void print(Printer & this, const char * const text ) {}
    36         static inline void print(Printer & this, const char * const text, int i ) {}
    3732#endif
    38 Printer printer;
    3933
    4034coroutine Coroutine {};
     
    5852        for(int i = 0; TEST(i < N); i++) {
    5953
    60                 print(printer, "Coroutine 1", i);
     54                print("C - Suspending");
    6155                void publish() {
     56                        print("C - Publishing");
    6257                        assert(!the_cor);
    6358                        store( this );
     
    6560                suspend_then(publish);
    6661                assert(!the_cor);
    67                 print(printer, "Coroutine 2");
     62                print("Coroutine 2");
    6863                KICK_WATCHDOG;
    6964                yield();
     
    8277                if(!mine) continue;
    8378
    84                 print(printer, "Thread 1");
     79                print("T - took");
    8580                resume(*mine);
    86                 print(printer, "Thread 2");
     81                print("T - back");
    8782        }
    8883}
Note: See TracChangeset for help on using the changeset viewer.