From: g0dil Date: Tue, 13 Jan 2009 08:34:29 +0000 (+0000) Subject: PPI: Add methods to IntervalTimer to change the timer interval X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=6c2e219461255d29b71c1e81e9461bfb2cd27fe2;p=senf.git PPI: Add methods to IntervalTimer to change the timer interval git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1060 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/IntervalTimer.cc b/PPI/IntervalTimer.cc index f0dafd1..e4dff93 100644 --- a/PPI/IntervalTimer.cc +++ b/PPI/IntervalTimer.cc @@ -42,6 +42,8 @@ prefix_ void senf::ppi::IntervalTimer::v_enable() { + if (eventsPerInterval_ <= 0) + return; info_.intervalStart = manager().now(); info_.number = 0; schedule(); diff --git a/PPI/IntervalTimer.cci b/PPI/IntervalTimer.cci index afa7ba3..674ff7e 100644 --- a/PPI/IntervalTimer.cci +++ b/PPI/IntervalTimer.cci @@ -34,9 +34,29 @@ prefix_ senf::ppi::IntervalTimer::IntervalTimer(ClockService::clock_type interval, unsigned eventsPerInterval) : interval_ (interval), eventsPerInterval_ (eventsPerInterval), - timer_("senf::ppi::IntervalTimer", boost::bind(&IntervalTimer::cb,this)) + timer_ ("senf::ppi::IntervalTimer", boost::bind(&IntervalTimer::cb,this)) {} +prefix_ senf::ppi::IntervalTimer::IntervalTimer() + : interval_ (0), eventsPerInterval_ (0), + timer_ ("senf::ppi::IntervalTimer", boost::bind(&IntervalTimer::cb,this)) +{} + +prefix_ void senf::ppi::IntervalTimer::interval(ClockService::clock_type interval, + unsigned eventsPerInterval) +{ + enabled(false); + interval_ = interval; + eventsPerInterval_ = eventsPerInterval; + enabled(true); +} + +prefix_ std::pair senf::ppi::IntervalTimer::interval() + const +{ + return std::make_pair(interval_, eventsPerInterval_); +} + ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/PPI/IntervalTimer.hh b/PPI/IntervalTimer.hh index 98228e4..959c48c 100644 --- a/PPI/IntervalTimer.hh +++ b/PPI/IntervalTimer.hh @@ -66,10 +66,14 @@ namespace ppi { explicit IntervalTimer(ClockService::clock_type interval, unsigned eventsPerInterval=1); - + IntervalTimer(); + ///@} /////////////////////////////////////////////////////////////////////////// + void interval(ClockService::clock_type interval, unsigned eventsPerInterval=1); + std::pair interval() const; + protected: private: