source: src/tests/concurrent/coroutineYield.c @ 70969f8

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 70969f8 was 70969f8, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Updated longrun tests have a more consistent duration

  • Property mode set to 100644
File size: 513 bytes
Line 
1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
5
6#ifdef LONG_TEST
7static const unsigned long N = 600_000ul;
8#else
9static const unsigned long N = 1_000ul;
10#endif
11
12coroutine Coroutine {};
13
14void main(Coroutine& this) {
15        while(true) {
16                sout | "Coroutine 1" | endl;
17                yield();
18                sout | "Coroutine 2" | endl;
19                suspend();
20        }
21}
22
23
24int main(int argc, char* argv[]) {
25        Coroutine c;
26        for(int i = 0; i < N; i++) {
27                sout | "Thread 1" | endl;
28                resume(c);
29                sout | "Thread 2" | endl;
30                yield();
31        }
32}
Note: See TracBrowser for help on using the repository browser.