source: tests/concurrent/sleep.cfa @ ab388c5

arm-ehenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-expr
Last change on this file since ab388c5 was c457dc4, checked in by Thierry Delisle <tdelisle@…>, 12 months 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.