source: src/tests/concurrent/coroutineYield.c @ ea8b2f7

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

Fixed long run tests

  • Property mode set to 100644
File size: 651 bytes
RevLine 
[82c948c]1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
[b9da9585]5#include <time>
6
7#ifndef PREEMPTION_RATE
8#define PREEMPTION_RATE 10`ms
9#endif
10
11Duration default_preemption() {
12        return PREEMPTION_RATE;
13}
[82c948c]14
[70969f8]15#ifdef LONG_TEST
16static const unsigned long N = 600_000ul;
17#else
18static const unsigned long N = 1_000ul;
19#endif
20
[82c948c]21coroutine Coroutine {};
22
23void main(Coroutine& this) {
[7323573]24        while(true) {
25                sout | "Coroutine 1" | endl;
26                yield();
27                sout | "Coroutine 2" | endl;
28                suspend();
29        }
[82c948c]30}
31
32
33int main(int argc, char* argv[]) {
34        Coroutine c;
[70969f8]35        for(int i = 0; i < N; i++) {
[7323573]36                sout | "Thread 1" | endl;
37                resume(c);
38                sout | "Thread 2" | endl;
39                yield();
40        }
[82c948c]41}
Note: See TracBrowser for help on using the repository browser.