WvStreams
wvstreamex7.cc
1/*
2 * A WvStream example.
3 *
4 * Some text about this example...
5 */
6
7#include <wvstream.h>
8
9int main()
10{
11 int nothing_count = 0;
12 wvcon->autoforward(*wvcon);
13
14 while (wvcon->isok())
15 {
16 if (wvcon->select(1000))
17 {
18 nothing_count = 0;
19 wvcon->callback();
20 }
21 else
22 {
23 nothing_count++;
24 wvcon->print("[TICK]");
25 if (nothing_count == 10)
26 {
27 wvcon->print("[TIMEOUT]\n");
28 break;
29 }
30 }
31 }
32}
virtual bool isok() const
return true if the stream is actually usable right now
Definition: wvstream.cc:445
void autoforward(WvStream &s)
set the callback function for this stream to an internal routine that auto-forwards all incoming stre...
Definition: wvstream.cc:362
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