source: tests/concurrent/sleep.cfa@ 77f1265

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 77f1265 was c457dc41, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Fix sequential handling of timers

  • Property mode set to 100644
File size: 576 bytes
Line 
1#include <fstream.hfa>
2#include <thread.hfa>
3#include <time.hfa>
4
5Duration default_preemption() {
6 return 0;
7}
8
9thread fast_sleeper {};
10void main(fast_sleeper &) {
11 Duration wait = 47`ms;
12 for(i; 20) {
13 sleep(wait);
14 sout | acquire | "fast loop" | ((1 + i) * wait);
15 }
16}
17
18thread slow_sleeper {};
19void main(slow_sleeper &) {
20 Duration wait = 277`ms;
21 for(i; 4) {
22
23 sleep(wait);
24 sout | acquire | "slow loop" | ((1 + i) * wait);
25 }
26}
27
28int main() {
29 sout | acquire | "start";
30 {
31 slow_sleeper slow;
32 yield();
33 fast_sleeper fast;
34 yield();
35 }
36 sout | acquire | "done";
37}
38
Note: See TracBrowser for help on using the repository browser.