-
Notifications
You must be signed in to change notification settings - Fork 78
/
countertest.hh
53 lines (43 loc) · 1.27 KB
/
countertest.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
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_COUNTERTEST_HH
#define CLICK_COUNTERTEST_HH
#include <click/batchelement.hh>
#include "../standard/counter.hh"
CLICK_DECLS
/*
=c
CounterTest()
=s test
Call read_atomic on the counter in a certain proportion regarding the batch
it passes.
*/
class CounterTest : public BatchElement {
public:
CounterTest() CLICK_COLD;
const char *class_name() const override { return "CounterTest"; }
const char *port_count() const override { return "0-1/1"; }
const char *processing() const override { return PUSH; }
int configure(Vector<String>&, ErrorHandler*) override;
bool run_task(Task *) override;
void push(int, Packet* p) override;
#if HAVE_BATCH
void push_batch(int, PacketBatch* batch) override;
#endif
void add_handlers() override;
private:
CounterBase* _counter;
int _rate;
unsigned long _read;
unsigned long _write;
bool _atomic;
bool _standalone;
Task _task;
int _pass;
per_thread<int> _cur_pass;
#if defined(__GNUC__) && !defined(__clang__)
void(*_add_fnt)(CounterBase*,CounterBase::stats);
CounterBase::stats(*_read_fnt)(CounterBase*);
#endif
};
CLICK_ENDDECLS
#endif