// $Id$ // // Copyright (C) 2006 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file \brief Scheduler inline non-template implementation */ //#include "Scheduler.ih" // Custom includes #include #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// // private members prefix_ void senf::Scheduler::do_add(int fd, FdCallback const & cb, int eventMask) { do_add((boost::format("") % fd).str(), fd, cb, eventMask); } prefix_ void senf::Scheduler::do_add(std::string const & name, int fd, FdCallback const & cb, int eventMask) { if (! fdDispatcher_.add(name, fd, cb, eventMask)) fileDispatcher_.add(name, fd, cb, eventMask); } prefix_ void senf::Scheduler::do_remove(int fd, int eventMask) { // We don't know, where the descriptor is registered. However, this is no problem since removing // a non-registered fd is a no-opp fdDispatcher_.remove(fd, eventMask); fileDispatcher_.remove(fd, eventMask); } // public members prefix_ senf::Scheduler::Scheduler & senf::Scheduler::instance() { static Scheduler instance; return instance; } prefix_ int senf::retrieve_filehandle(int fd) { return fd; } prefix_ senf::Scheduler::timer_id senf::Scheduler::timeout(ClockService::clock_type timeout, SimpleCallback const & cb) { return timerDispatcher_.add("", timeout, cb); } prefix_ senf::Scheduler::timer_id senf::Scheduler::timeout(std::string const & name, ClockService::clock_type timeout, SimpleCallback const & cb) { return timerDispatcher_.add(name, timeout, cb); } prefix_ void senf::Scheduler::cancelTimeout(timer_id id) { timerDispatcher_.remove(id); } prefix_ senf::ClockService::clock_type senf::Scheduler::timeoutEarly() const { SENF_LOG( (senf::log::IMPORTANT) ("timeoutEarly() is deprecated and a no-op. It will be removed") ); return 0; } prefix_ void senf::Scheduler::timeoutEarly(ClockService::clock_type v) { SENF_LOG( (senf::log::IMPORTANT) ("timeoutEarly() is deprecated and a no-op. It will be removed") ); } prefix_ senf::ClockService::clock_type senf::Scheduler::timeoutAdjust() const { SENF_LOG( (senf::log::IMPORTANT) ("timeoutAdjust() is deprecated and a no-op. It will be removed") ); return 0; } prefix_ void senf::Scheduler::timeoutAdjust(ClockService::clock_type v) { SENF_LOG( (senf::log::IMPORTANT) ("timeoutAdjust() is deprecated and a no-op. It will be removed") ); } prefix_ void senf::Scheduler::registerSignal(unsigned signal, SignalCallback const & cb) { signalDispatcher_.add(signal, cb); } prefix_ void senf::Scheduler::unregisterSignal(unsigned signal) { signalDispatcher_.remove(signal); } prefix_ void senf::Scheduler::terminate() { terminate_ = true; } prefix_ senf::ClockService::clock_type senf::Scheduler::eventTime() const { return manager_.eventTime(); } prefix_ void senf::Scheduler::taskTimeout(unsigned ms) { runner_.taskTimeout(ms); } prefix_ unsigned senf::Scheduler::taskTimeout() const { return runner_.taskTimeout(); } prefix_ unsigned senf::Scheduler::hangCount() const { return runner_.hangCount(); } prefix_ senf::Scheduler::Scheduler() : terminate_ (false), fdDispatcher_ (manager_, runner_), timerDispatcher_ (manager_, runner_), signalDispatcher_ (manager_, runner_), fileDispatcher_ (manager_, runner_) {} ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // comment-column: 40 // End: