Fix some lines that exceed 80 characters.
[wvstreams.git] / include / wvtimestream.h
bloba3be43f3f104bca3e68fa818316c25abc6252138
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 */
6 #ifndef __WVTIMESTREAM_H
7 #define __WVTIMESTREAM_H
9 #include "wvtimeutils.h"
10 #include "wvstream.h"
12 /**
13 * WvTimeStream causes select() to be true after a configurable number
14 * of milliseconds. Because programs using WvStream make no guarantees
15 * about how often select() will be called, WvTimeStream tries to adjust
16 * its timing to a correct _average_ number of milliseconds per tick.
18 * For example, if ms_per_tick=100, WvTimeStream will tick 10 times in one
19 * second. However, there may be a few milliseconds of difference
20 * ("jitter") for each individual tick, due to random system delays.
22 class WvTimeStream : public WvStream
24 WvTime last;
25 WvTime next;
26 time_t ms_per_tick;
28 public:
29 WvTimeStream();
31 /**
32 * Every 'msec' milliseconds, select() will return true on this
33 * stream. if 'msec' is 0 (or less), the timer is disabled.
35 * Be careful when mixing alarm() with this. You can know whether
36 * it was the alarm or if you had a timer event by looking at
37 * alarm_was_ticking. But the alarm() has priority, so if there's
38 * always an alarm, the timer event never gets to run. Calling
39 * alarm(0) in the callback unconditionally would thus be a bad
40 * idea, or even with an unsuitably small number (say, less than
41 * the time it takes to go back into select()). So don't do it.
43 void set_timer(time_t msec);
45 virtual bool isok() const;
46 virtual void pre_select(SelectInfo &si);
47 virtual bool post_select(SelectInfo &si);
48 virtual void execute();
50 public:
51 const char *wstype() const { return "WvTimeStream"; }
55 #endif // __WVTIMESTREAM_H