// $Id$ // // Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \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: