ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
with_gc
Last change
on this file since 8eb2018 was 70969f8, checked in by Thierry Delisle <tdelisle@…>, 8 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
|
---|
7 | static const unsigned long N = 600_000ul;
|
---|
8 | #else
|
---|
9 | static const unsigned long N = 1_000ul;
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | coroutine Coroutine {};
|
---|
13 |
|
---|
14 | void main(Coroutine& this) {
|
---|
15 | while(true) {
|
---|
16 | sout | "Coroutine 1" | endl;
|
---|
17 | yield();
|
---|
18 | sout | "Coroutine 2" | endl;
|
---|
19 | suspend();
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 |
|
---|
24 | int 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.