WvStreams
wvtimeex.cc
00001 /*
00002  * A WvTimeStream example.
00003  *
00004  * This program should take exactly ten seconds to run, but
00005  * tests how well the time stream handles being executed in bursts.
00006  */
00007 
00008 #include "wvtimestream.h"
00009 #include "wvlog.h"
00010 #include <sys/time.h>
00011 
00012 int main()
00013 {
00014     WvLog log("time", WvLog::Info);
00015     WvTimeStream t;
00016     int count;
00017     
00018     log("Artificial burstiness - should take exactly 10 seconds\n");
00019 
00020     t.set_timer(100);
00021 
00022     for (count = 0; count < 100; count++)
00023     {
00024         if (!(count % 10)) log("\n");
00025 
00026         while (!t.select(5*(100-count)))
00027             ;
00028         t.callback();
00029 
00030         log("%02s ", count);
00031     }
00032 
00033     return 0;
00034 }