From: tho Date: Thu, 28 May 2009 07:40:48 +0000 (+0000) Subject: Scheduler/TimerEvent: added "Idle"-Event to demonstrate Timer-Problem X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ab8eec77ea8e430df387ed1b987ab7137ea7f0d8;p=senf.git Scheduler/TimerEvent: added "Idle"-Event to demonstrate Timer-Problem git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1216 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/TimerEvent.test.cc b/Scheduler/TimerEvent.test.cc index ae91a56..92e3f77 100644 --- a/Scheduler/TimerEvent.test.cc +++ b/Scheduler/TimerEvent.test.cc @@ -100,9 +100,9 @@ namespace { void jitterCb(senf::scheduler::TimerEvent & tm) { - std::cerr << senf::scheduler::now() << ' ' << tm.timeout() << '\n'; + std::cerr << "diff:" << senf::ClockService::in_microseconds( senf::scheduler::now() - tm.timeout()) << '\n'; count ++; - delay += senf::scheduler::now() - tm.timeout(); + delay += senf::ClockService::in_microseconds( senf::scheduler::now() - tm.timeout()); haveCb = true; tm.timeout(randomDelay()); } @@ -118,6 +118,11 @@ namespace { std::cerr << senf::scheduler::now() << '\n'; } + void idleCb(senf::scheduler::TimerEvent & tm) + { + tm.timeout( senf::scheduler::now()); + } + void jitterTest() { count = 0; @@ -127,13 +132,17 @@ namespace { senf::scheduler::EventHook post ("jitterTest::postCb", &postCb, senf::scheduler::EventHook::POST); - senf::scheduler::TimerEvent tm1 ("jitterTest::tm1", boost::bind(&jitterCb, boost::ref(tm1)), - randomDelay()); - senf::scheduler::TimerEvent tm2 ("jitterTest::tm2", boost::bind(&jitterCb, boost::ref(tm2)), - randomDelay()); - senf::scheduler::TimerEvent tm3 ("jitterTest::tm3", boost::bind(&jitterCb, boost::ref(tm3)), - randomDelay()); + senf::scheduler::TimerEvent tm1 ( + "jitterTest::tm1", boost::bind(&jitterCb, boost::ref(tm1)), randomDelay()); + senf::scheduler::TimerEvent tm2 ( + "jitterTest::tm2", boost::bind(&jitterCb, boost::ref(tm2)), randomDelay()); + senf::scheduler::TimerEvent tm3 ( + "jitterTest::tm3", boost::bind(&jitterCb, boost::ref(tm3)), randomDelay()); + // enabled "Idle"-Event will degrade scheduling delay + //senf::scheduler::TimerEvent idle ( + // "jitterTest::idle", boost::bind(&idleCb, boost::ref(idle)), senf::scheduler::now()); + senf::scheduler::TimerEvent timeout("jitterTest::timeout", &senf::scheduler::terminate, senf::scheduler::now() + senf::ClockService::seconds(5));