WvStreams
wvtimeoutex.cc
1 /*
2  * A WvTimeOut example.
3  *
4  * Should only fire once.
5  */
6 
7 #include "wvtimeoutstream.h"
8 #include "wvlog.h"
9 #include <sys/time.h>
10 
11 WvLog log("timeout", WvLog::Info);
12 
13 void timeout(WvStream &s, void *userdata)
14 {
15  static int count = 0;
16  count++;
17  log("Fire %s\n", count);
18 }
19 
20 int main()
21 {
22  WvTimeoutStream t(1000);
23  t.setcallback(timeout, NULL);
24 
25  for (int i = 0; i < 3 && t.isok(); i++)
26  {
27  if (t.select(-1))
28  t.callback();
29  }
30 
31  return 0;
32 }
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
WvTimeoutStream
WvTimeoutStream is a stream that becomes !isok() after a configurable number of milliseconds.
Definition: wvtimeoutstream.h:20
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24