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

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
Line 
1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
5
6coroutine Coroutine {};
7
8void main(Coroutine& this) {
9        while(true) {
10                sout | "Coroutine 1" | endl;
11                yield();
12                sout | "Coroutine 2" | endl;
13                suspend();
14        }
15}
16
17
18int main(int argc, char* argv[]) {
19        Coroutine c;
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        }
26}
Note: See TracBrowser for help on using the repository browser.