Commit 6d73a1cc authored by Tom Barbette's avatar Tom Barbette

CounterTest: allow to pass some read

parent e1d37894
Pipeline #1847 passed with stage
in 10 minutes and 51 seconds
......@@ -24,7 +24,7 @@
CLICK_DECLS
CounterTest::CounterTest() : _counter(0), _rate(0), _atomic(true), _standalone(false), _task(this), _read(0), _write(0)
CounterTest::CounterTest() : _counter(0), _rate(0), _atomic(true), _standalone(false), _task(this), _read(0), _write(0), _pass(1)
{
}
......@@ -38,6 +38,7 @@ CounterTest::configure(Vector<String> &conf, ErrorHandler *errh)
.read_mp("RATE", _rate)
.read("ATOMIC", _atomic)
.read("STANDALONE", _standalone)
.read("PASS", _pass)
.complete() < 0)
return -1;
_counter = (CounterBase*)e->cast("CounterBase");
......@@ -56,19 +57,24 @@ CounterTest::configure(Vector<String> &conf, ErrorHandler *errh)
_add_fnt=(void (*)(CounterBase*,CounterBase::stats))(_counter->*addfnt);
_read_fnt=(CounterBase::stats(*)(CounterBase*))(_counter->*readfnt);
}
if (_pass < 1)
return errh->error("PASS must be >= 1");
return 0;
}
#if HAVE_BATCH
void
CounterTest::push_batch(int, PacketBatch* batch) {
for (int i = 0; i < _rate; i++) {
if (!router()->running())
break;
if (_atomic) {
_read_fnt(_counter);
} else {
_counter->count();
if (++_cur_pass == _pass) {
_cur_pass.set(0);
for (int i = 0; i < _rate; i++) {
if (!router()->running())
break;
if (_atomic) {
_read_fnt(_counter);
} else {
_counter->count();
}
}
}
output_push_batch(0, batch);
......
......@@ -40,6 +40,8 @@ private:
bool _atomic;
bool _standalone;
Task _task;
int _pass;
per_thread<int> _cur_pass;
void(*_add_fnt)(CounterBase*,CounterBase::stats);
CounterBase::stats(*_read_fnt)(CounterBase*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment