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
11WvLog log("timeout", WvLog::Info);
12
13void timeout(WvStream &s, void *userdata)
14{
15 static int count = 0;
16 count++;
17 log("Fire %s\n", count);
18}
19
20int 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}
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition wvlog.h:57
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition wvstream.h:25
WvTimeoutStream is a stream that becomes !isok() after a configurable number of milliseconds.