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 e61de5b was
7323573,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Extended test to allow preemption to occur
|
-
Property mode set to
100644
|
File size:
404 bytes
|
Rev | Line | |
---|
[82c948c] | 1 | #include <fstream> |
---|
| 2 | #include <kernel> |
---|
| 3 | #include <stdlib> |
---|
| 4 | #include <thread> |
---|
| 5 | |
---|
| 6 | coroutine Coroutine {}; |
---|
| 7 | |
---|
| 8 | void main(Coroutine& this) { |
---|
[7323573] | 9 | while(true) { |
---|
| 10 | sout | "Coroutine 1" | endl; |
---|
| 11 | yield(); |
---|
| 12 | sout | "Coroutine 2" | endl; |
---|
| 13 | suspend(); |
---|
| 14 | } |
---|
[82c948c] | 15 | } |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | int main(int argc, char* argv[]) { |
---|
| 19 | Coroutine c; |
---|
[7323573] | 20 | for(int i = 0; i < 1_000; i++) { |
---|
| 21 | sout | "Thread 1" | endl; |
---|
| 22 | resume(c); |
---|
| 23 | sout | "Thread 2" | endl; |
---|
| 24 | yield(); |
---|
| 25 | } |
---|
[82c948c] | 26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.