4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief TimerDispatcher non-inline non-template implementation */
26 #include "TimerEvent.hh"
27 #include "TimerEvent.ih"
32 //#include "TimerEvent.mpp"
34 ///////////////////////////////cc.p////////////////////////////////////////
36 prefix_ senf::scheduler::detail::TimerDispatcher::TimerDispatcher()
37 : source_ (new PollTimerSource())
40 prefix_ senf::scheduler::detail::TimerDispatcher::~TimerDispatcher()
42 TimerSet::iterator i (timers_.begin());
43 TimerSet::iterator const i_end (timers_.end());
44 for (; i != i_end; ++i)
45 senf::scheduler::detail::FIFORunner::instance().dequeue(&(*i));
48 void senf::scheduler::detail::TimerDispatcher::add(TimerEvent & event)
50 TimerSet::iterator i (timers_.insert(event));
51 senf::scheduler::detail::FIFORunner::instance().enqueue(&(*i));
54 prefix_ void senf::scheduler::detail::TimerDispatcher::remove(TimerEvent & event)
56 TimerSet::iterator i (TimerSet::current(event));
57 if (i == timers_.end())
59 senf::scheduler::detail::FIFORunner::instance().dequeue(&(*i));
63 prefix_ void senf::scheduler::detail::TimerDispatcher::prepareRun()
65 TimerSet::iterator i (timers_.begin());
66 TimerSet::iterator const i_end (timers_.end());
67 ClockService::clock_type now (senf::scheduler::detail::FdManager::instance().eventTime());
68 for (; i != i_end && i->timeout_ <= now ; ++i)
72 prefix_ void senf::scheduler::detail::TimerDispatcher::reschedule()
77 source_->timeout(timers_.begin()->timeout_);
80 ///////////////////////////////////////////////////////////////////////////
81 // senf::scheduler::detail::TimerDispatcher::TimerEvent
83 prefix_ void senf::scheduler::TimerEvent::v_run()
89 prefix_ char const * senf::scheduler::TimerEvent::v_type()
95 prefix_ std::string senf::scheduler::TimerEvent::v_info()
99 ss.imbue( std::locale(ss.getloc(),
100 new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S.%f-0000")) );
101 ss << "expire " << ClockService::abstime(timeout_);
105 ///////////////////////////////cc.e////////////////////////////////////////
107 //#include "TimerEvent.mpp"
113 // comment-column: 40
114 // c-file-style: "senf"
115 // indent-tabs-mode: nil
116 // ispell-local-dictionary: "american"
117 // compile-command: "scons -u test"