-
Notifications
You must be signed in to change notification settings - Fork 82
/
timertest.hh
92 lines (57 loc) · 2.1 KB
/
timertest.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_TIMERTEST_HH
#define CLICK_TIMERTEST_HH
#include <click/element.hh>
#include <click/timer.hh>
CLICK_DECLS
/*
=c
TimerTest([I<keywords>])
=s test
runs regression tests for Timer
=d
Without other arguments, TimerTest runs regression tests for Click's Timer
class at initialization time.
TimerTest includes a timer which prints a message when scheduled. This timer
is controlled by the DELAY and/or SCHEDULED keyword arguments and several
handlers.
TimerTest does not route packets.
Keyword arguments are:
=over 8
=item DELAY
Timestamp. If set, TimerTest schedules a timer starting DELAY seconds in the
future. On expiry, a message such as "C<1000000000.010000: t1 :: TimerTest fired>"
is printed to standard error.
=item BENCHMARK
Integer. If set to a positive number, then TimerTest runs a timer
manipulation benchmark at installation time involving BENCHMARK total
timers. Default is 0 (don't benchmark).
=back
=h scheduled rw
Boolean. Returns whether the TimerTest's timer is scheduled.
=h expiry r
Timestamp. Returns the expiration time for the TimerTest's timer, if any.
=h schedule_after w
Schedule the TimerTest's timer to fire after a given time.
=h unschedule w
Unschedule the TimerTest's timer.
*/
class TimerTest : public Element { public:
TimerTest() CLICK_COLD;
const char *class_name() const override { return "TimerTest"; }
int configure(Vector<String> &conf, ErrorHandler *errh) CLICK_COLD;
int initialize(ErrorHandler *errh) CLICK_COLD;
void add_handlers() CLICK_COLD;
void run_timer(Timer *t);
private:
Timer _timer;
int _benchmark;
void benchmark_schedules(Timer *ts, int nts, const Timestamp &now);
void benchmark_changes(Timer *ts, int nts, const Timestamp &now);
void benchmark_fires(Timer *ts, int nts, const Timestamp &now);
enum { h_scheduled, h_expiry, h_schedule_after, h_unschedule };
static String read_handler(Element *e, void *user_data) CLICK_COLD;
static int write_handler(const String &str, Element *e, void *user_data, ErrorHandler *errh) CLICK_COLD;
};
CLICK_ENDDECLS
#endif