4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief FIFORunner inline non-template implementation */
31 //#include "FIFORunner.ih"
36 #include <senf/Utils/Backtrace.hh>
39 #define prefix_ inline
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
43 // senf::scheduler::detail::FIFORunner::TaskInfo
45 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string const & name,
47 : Event(name), runnable_ (false), priority_ (priority)
51 senf::backtrace(ss, 32);
52 backtrace_ = ss.str();
56 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::~TaskInfo()
59 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::setRunnable()
64 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run()
67 // Be sure to run v_run last since the callback may destroy this instance
71 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::runnable()
77 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::v_enabled()
80 return TaskListBase::linked();
83 //-/////////////////////////////////////////////////////////////////////////////////////////////////
84 // senf::scheduler::detail::FIFORunner::NullTask
86 prefix_ senf::scheduler::detail::FIFORunner::NullTask::NullTask()
87 : senf::scheduler::detail::FIFORunner::TaskInfo ("<null>")
90 prefix_ senf::scheduler::detail::FIFORunner::NullTask::~NullTask()
92 if (TaskListBase::linked())
93 FIFORunner::instance().dequeue(this);
96 prefix_ void senf::scheduler::detail::FIFORunner::NullTask::v_run()
99 prefix_ char const * senf::scheduler::detail::FIFORunner::NullTask::v_type()
105 prefix_ std::string senf::scheduler::detail::FIFORunner::NullTask::v_info()
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
112 // senf::scheduler::detail::FIFORunner
114 prefix_ void senf::scheduler::detail::FIFORunner::enqueue(TaskInfo * task)
116 tasks_.insert(priorityEnd(task->priority_), *task);
119 prefix_ void senf::scheduler::detail::FIFORunner::taskTimeout(unsigned ms)
122 if (watchdogRunning_)
126 prefix_ unsigned senf::scheduler::detail::FIFORunner::taskTimeout()
132 prefix_ void senf::scheduler::detail::FIFORunner::abortOnTimeout(bool flag)
134 watchdogAbort_ = flag;
137 prefix_ bool senf::scheduler::detail::FIFORunner::abortOnTimeout()
140 return watchdogAbort_;
143 prefix_ unsigned senf::scheduler::detail::FIFORunner::hangCount()
145 unsigned hc (hangCount_);
150 prefix_ senf::scheduler::detail::FIFORunner::iterator
151 senf::scheduler::detail::FIFORunner::begin()
154 // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added is such
155 // an element and must be skipped.
156 return boost::make_filter_iterator(
157 EventManager::IteratorFilter(), tasks_.begin(), tasks_.end());
160 prefix_ senf::scheduler::detail::FIFORunner::iterator senf::scheduler::detail::FIFORunner::end()
163 return boost::make_filter_iterator(
164 EventManager::IteratorFilter(), tasks_.end(), tasks_.end());
167 prefix_ void senf::scheduler::detail::FIFORunner::yield()
172 //-/////////////////////////////////////////////////////////////////////////////////////////////////
179 // comment-column: 40
180 // c-file-style: "senf"
181 // indent-tabs-mode: nil
182 // ispell-local-dictionary: "american"
183 // compile-command: "scons -u test"