WvStreams
wvtimeex.cc
1 /*
2  * A WvTimeStream example.
3  *
4  * This program should take exactly ten seconds to run, but
5  * tests how well the time stream handles being executed in bursts.
6  */
7 
8 #include "wvtimestream.h"
9 #include "wvlog.h"
10 #include <sys/time.h>
11 
12 int main()
13 {
14  WvLog log("time", WvLog::Info);
15  WvTimeStream t;
16  int count;
17 
18  log("Artificial burstiness - should take exactly 10 seconds\n");
19 
20  t.set_timer(100);
21 
22  for (count = 0; count < 100; count++)
23  {
24  if (!(count % 10)) log("\n");
25 
26  while (!t.select(5*(100-count)))
27  ;
28  t.callback();
29 
30  log("%02s ", count);
31  }
32 
33  return 0;
34 }