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