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

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 resolv-new with_gc
Last change on this file since d27e340 was 7323573, checked in by Thierry Delisle <tdelisle@…>, 8 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.