ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since afd7faf was
c457dc41,
checked in by Thierry Delisle <tdelisle@…>, 3 years ago
|
Fix sequential handling of timers
|
-
Property mode set to
100644
|
File size:
576 bytes
|
Rev | Line | |
---|
[c457dc41] | 1 | #include <fstream.hfa> |
---|
| 2 | #include <thread.hfa> |
---|
| 3 | #include <time.hfa> |
---|
| 4 | |
---|
| 5 | Duration default_preemption() { |
---|
| 6 | return 0; |
---|
| 7 | } |
---|
| 8 | |
---|
| 9 | thread fast_sleeper {}; |
---|
| 10 | void 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 | |
---|
| 18 | thread slow_sleeper {}; |
---|
| 19 | void 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 | |
---|
| 28 | int 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.