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
12int main()
13{
14 WvLog log("time", WvLog::Info);
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}
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:57
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
Definition: wvstream.h:376
virtual void callback()
if the stream has a callback function defined, call it now.
Definition: wvstream.cc:401
WvTimeStream causes select() to be true after a configurable number of milliseconds.
Definition: wvtimestream.h:23
void set_timer(time_t msec)
Every 'msec' milliseconds, select() will return true on this stream.
Definition: wvtimestream.cc:15