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 Scheduler inline non-template implementation
27 //#include "Scheduler.ih"
30 #include <boost/format.hpp>
32 #define prefix_ inline
33 ///////////////////////////////cci.p///////////////////////////////////////
37 prefix_ void senf::Scheduler::do_add(int fd, FdCallback const & cb, int eventMask)
39 do_add((boost::format("<anon fd %d>") % fd).str(), fd, cb, eventMask);
42 prefix_ void senf::Scheduler::do_add(std::string const & name, int fd, FdCallback const & cb,
45 if (! fdDispatcher_.add(name, fd, cb, eventMask))
46 fileDispatcher_.add(name, fd, cb, eventMask);
49 prefix_ void senf::Scheduler::do_remove(int fd, int eventMask)
51 // We don't know, where the descriptor is registered. However, this is no problem since removing
52 // a non-registered fd is a no-opp
53 fdDispatcher_.remove(fd, eventMask);
54 fileDispatcher_.remove(fd, eventMask);
59 prefix_ senf::Scheduler::Scheduler & senf::Scheduler::instance()
61 static Scheduler instance;
65 prefix_ int senf::retrieve_filehandle(int fd)
70 prefix_ senf::Scheduler::timer_id senf::Scheduler::timeout(ClockService::clock_type timeout,
71 SimpleCallback const & cb)
73 return timerDispatcher_.add("<anon timer>", timeout, cb);
76 prefix_ senf::Scheduler::timer_id senf::Scheduler::timeout(std::string const & name,
77 ClockService::clock_type timeout,
78 SimpleCallback const & cb)
80 return timerDispatcher_.add(name, timeout, cb);
83 prefix_ void senf::Scheduler::cancelTimeout(timer_id id)
85 timerDispatcher_.remove(id);
88 prefix_ senf::ClockService::clock_type senf::Scheduler::timeoutEarly()
91 SENF_LOG( (senf::log::IMPORTANT)
92 ("timeoutEarly() is deprecated and a no-op. It will be removed") );
96 prefix_ void senf::Scheduler::timeoutEarly(ClockService::clock_type v)
98 SENF_LOG( (senf::log::IMPORTANT)
99 ("timeoutEarly() is deprecated and a no-op. It will be removed") );
102 prefix_ senf::ClockService::clock_type senf::Scheduler::timeoutAdjust()
105 SENF_LOG( (senf::log::IMPORTANT)
106 ("timeoutAdjust() is deprecated and a no-op. It will be removed") );
110 prefix_ void senf::Scheduler::timeoutAdjust(ClockService::clock_type v)
112 SENF_LOG( (senf::log::IMPORTANT)
113 ("timeoutAdjust() is deprecated and a no-op. It will be removed") );
116 prefix_ void senf::Scheduler::registerSignal(unsigned signal, SignalCallback const & cb)
118 signalDispatcher_.add(signal, cb);
121 prefix_ void senf::Scheduler::unregisterSignal(unsigned signal)
123 signalDispatcher_.remove(signal);
126 prefix_ void senf::Scheduler::terminate()
131 prefix_ senf::ClockService::clock_type senf::Scheduler::eventTime()
134 return manager_.eventTime();
137 prefix_ void senf::Scheduler::taskTimeout(unsigned ms)
139 runner_.taskTimeout(ms);
142 prefix_ unsigned senf::Scheduler::taskTimeout()
145 return runner_.taskTimeout();
148 prefix_ unsigned senf::Scheduler::hangCount()
151 return runner_.hangCount();
154 prefix_ senf::Scheduler::Scheduler()
155 : terminate_ (false),
156 fdDispatcher_ (manager_, runner_),
157 timerDispatcher_ (manager_, runner_),
158 signalDispatcher_ (manager_, runner_),
159 fileDispatcher_ (manager_, runner_)
162 ///////////////////////////////cci.e///////////////////////////////////////
169 // c-file-style: "senf"
170 // indent-tabs-mode: nil
171 // ispell-local-dictionary: "american"
172 // compile-command: "scons -u test"
173 // comment-column: 40