2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief FIFORunner inline non-template implementation */
17 //#include "FIFORunner.ih"
20 #include <senf/config.hh>
23 # include <senf/Utils/Backtrace.hh>
26 #define prefix_ inline
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 // senf::scheduler::detail::FIFORunner::TaskInfo
32 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string const & name,
34 : Event(name), runnable_ (false), priority_ (priority)
38 senf::backtrace(ss, 32);
39 backtrace_ = ss.str();
43 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::~TaskInfo()
46 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::setRunnable()
51 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run()
54 // Be sure to run v_run last since the callback may destroy this instance
58 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::runnable()
64 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::v_enabled()
67 return TaskListBase::is_linked();
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 // senf::scheduler::detail::FIFORunner::NullTask
73 prefix_ senf::scheduler::detail::FIFORunner::NullTask::NullTask()
74 : senf::scheduler::detail::FIFORunner::TaskInfo ("<null>")
77 prefix_ senf::scheduler::detail::FIFORunner::NullTask::~NullTask()
79 if (TaskListBase::is_linked())
80 FIFORunner::instance().dequeue(this);
83 prefix_ void senf::scheduler::detail::FIFORunner::NullTask::v_run()
86 prefix_ char const * senf::scheduler::detail::FIFORunner::NullTask::v_type()
92 prefix_ std::string senf::scheduler::detail::FIFORunner::NullTask::v_info()
98 //-/////////////////////////////////////////////////////////////////////////////////////////////////
99 // senf::scheduler::detail::FIFORunner
101 prefix_ void senf::scheduler::detail::FIFORunner::enqueue(TaskInfo * task)
103 tasks_.insert(priorityEnd(task->priority_), *task);
106 prefix_ void senf::scheduler::detail::FIFORunner::taskTimeout(unsigned ms)
109 if (watchdogRunning_)
113 prefix_ unsigned senf::scheduler::detail::FIFORunner::taskTimeout()
119 prefix_ void senf::scheduler::detail::FIFORunner::watchdogCallback(WatchdogCallback const & cb)
121 watchdogCallback_ = cb;
124 prefix_ void senf::scheduler::detail::FIFORunner::abortOnTimeout(bool flag)
126 watchdogAbort_ = flag;
129 prefix_ bool senf::scheduler::detail::FIFORunner::abortOnTimeout()
132 return watchdogAbort_;
135 prefix_ unsigned senf::scheduler::detail::FIFORunner::hangCount()
137 unsigned hc (hangCount_);
142 prefix_ senf::scheduler::detail::FIFORunner::iterator
143 senf::scheduler::detail::FIFORunner::begin()
146 // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added is such
147 // an element and must be skipped.
148 return boost::make_filter_iterator(
149 EventManager::IteratorFilter(), tasks_.begin(), tasks_.end());
152 prefix_ senf::scheduler::detail::FIFORunner::iterator senf::scheduler::detail::FIFORunner::end()
155 return boost::make_filter_iterator(
156 EventManager::IteratorFilter(), tasks_.end(), tasks_.end());
159 prefix_ void senf::scheduler::detail::FIFORunner::yield()
164 prefix_ void senf::scheduler::detail::FIFORunner::watchdogCheckpoint(const char * checkpoint)
166 watchdogCheckpoint_ = checkpoint;
169 //-/////////////////////////////////////////////////////////////////////////////////////////////////
176 // comment-column: 40
177 // c-file-style: "senf"
178 // indent-tabs-mode: nil
179 // ispell-local-dictionary: "american"
180 // compile-command: "scons -u test"