// $Id$ // // Copyright (C) 2008 // 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 FIFORunner inline non-template implementation */ //#include "FIFORunner.ih" // Custom includes #ifdef SENF_DEBUG #include #include #endif #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::scheduler::detail::FIFORunner::TaskInfo prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string const & name, Priority priority) : Event(name), runnable_ (false), priority_ (priority) { #ifdef SENF_BACKTRACE std::stringstream ss; senf::backtrace(ss, 32); backtrace_ = ss.str(); #endif } prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::~TaskInfo() {} prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::setRunnable() { runnable_ = true; } prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run() { countRun(); // Be sure to run v_run last since the callback may destroy this instance v_run(); } prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::runnable() const { return runnable_; } prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::v_enabled() const { return TaskListBase::linked(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::scheduler::detail::FIFORunner::NullTask prefix_ senf::scheduler::detail::FIFORunner::NullTask::NullTask() : senf::scheduler::detail::FIFORunner::TaskInfo ("") {} prefix_ senf::scheduler::detail::FIFORunner::NullTask::~NullTask() { if (TaskListBase::linked()) FIFORunner::instance().dequeue(this); } prefix_ void senf::scheduler::detail::FIFORunner::NullTask::v_run() {} prefix_ char const * senf::scheduler::detail::FIFORunner::NullTask::v_type() const { return 0; } prefix_ std::string senf::scheduler::detail::FIFORunner::NullTask::v_info() const { return ""; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::scheduler::detail::FIFORunner prefix_ void senf::scheduler::detail::FIFORunner::enqueue(TaskInfo * task) { tasks_.insert(priorityEnd(task->priority_), *task); } prefix_ void senf::scheduler::detail::FIFORunner::taskTimeout(unsigned ms) { watchdogMs_ = ms; if (watchdogRunning_) startWatchdog(); } prefix_ unsigned senf::scheduler::detail::FIFORunner::taskTimeout() const { return watchdogMs_; } prefix_ void senf::scheduler::detail::FIFORunner::abortOnTimeout(bool flag) { watchdogAbort_ = flag; } prefix_ bool senf::scheduler::detail::FIFORunner::abortOnTimeout() const { return watchdogAbort_; } prefix_ unsigned senf::scheduler::detail::FIFORunner::hangCount() { unsigned hc (hangCount_); hangCount_ = 0; return hc; } prefix_ senf::scheduler::detail::FIFORunner::iterator senf::scheduler::detail::FIFORunner::begin() const { // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added is such // an element and must be skipped. return boost::make_filter_iterator( EventManager::IteratorFilter(), tasks_.begin(), tasks_.end()); } prefix_ senf::scheduler::detail::FIFORunner::iterator senf::scheduler::detail::FIFORunner::end() const { return boost::make_filter_iterator( EventManager::IteratorFilter(), tasks_.end(), tasks_.end()); } prefix_ void senf::scheduler::detail::FIFORunner::yield() { yield_ = true; } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: