prefix_ void senf::scheduler::detail::EventManager::consoleEvents(std::ostream & os)
{
- iterator i (begin());
- iterator const i_end (end());
- // On an 80 column display, this wraps nicely directly before the RUN column
- os << boost::format("%-6s %-52s %-10s %-8s %7s %s\n")
- % "TYPE"
- % "NAME"
- % "ADDRESS"
- % "ACTIVE?"
- % "RUN"
- % "INFO";
- for (; i != i_end; ++i)
- os << boost::format("%-6.6s %-52.52s 0x%08x %-8.8s %7d %s\n")
- % i->type()
- % i->name()
- % reinterpret_cast<unsigned long>(&(*i))
- % (i->enabled() ? "enabled" : "disabled")
- % i->runCount()
- % i->info();
+ // On an 80 column display, this wraps nicely directly before the INFO column
+ boost::format fmt ("%s %-55.55s 0x%08x %8d %s %s\n");
+ os << boost::format("%s %-55.55s %-10s %8s %s %s\n")
+ % "TP" % "NAME" % "ADDRESS" % "RUNCNT" % "S" % "INFO";
+ {
+ FIFORunner::iterator i (FIFORunner::instance().begin());
+ FIFORunner::iterator const i_end (FIFORunner::instance().end());
+ for (; i != i_end; ++i)
+ os << fmt
+ % i->type()
+ % i->name()
+ % reinterpret_cast<unsigned long>(&(*i))
+ % i->runCount()
+ % (i->runnable() ? "R" : "W")
+ % i->info();
+ }
+ {
+ iterator i (begin());
+ iterator const i_end (end());
+ for (; i != i_end; ++i)
+ if (! i->enabled())
+ os << fmt
+ % i->type()
+ % i->name()
+ % reinterpret_cast<unsigned long>(&(*i))
+ % i->runCount()
+ % "-"
+ % i->info();
+ }
}
///////////////////////////////cc.e////////////////////////////////////////
{
// We need to filter out elements with e.type() == 0 ... the NullTask temporarily added
// by the FIFORunner is such an element and must be skipped.
- return boost::make_filter_iterator(IteratorFilter(), events_.begin(), events_.end());
+ return boost::make_filter_iterator(
+ IteratorFilter(), events_.begin(), events_.end());
}
prefix_ senf::scheduler::detail::EventManager::iterator
senf::scheduler::detail::EventManager::end()
const
{
- return boost::make_filter_iterator(IteratorFilter(), events_.end(), events_.end());
+ return boost::make_filter_iterator(
+ IteratorFilter(), events_.end(), events_.end());
}
///////////////////////////////cci.e///////////////////////////////////////
class EventManager
: public singleton<EventManager>
{
- struct IteratorFilter {
- bool operator()(Event const & e);
- };
-
public:
using singleton<EventManager>::instance;
using singleton<EventManager>::alive;
- typedef boost::filter_iterator<IteratorFilter, EventList::const_iterator> iterator;
+ struct IteratorFilter {
+ bool operator()(Event const & e);
+ };
+
+ typedef boost::filter_iterator<
+ IteratorFilter, EventList::const_iterator> iterator;
void add(Event & event);
void remove(Event & event);
prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run()
{
- v_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()
return hangCount_;
}
+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());
+}
+
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
void run();
+ bool runnable() const;
+
protected:
void setRunnable();
friend class FIFORunner;
};
+ typedef boost::filter_iterator<
+ EventManager::IteratorFilter, TaskList::const_iterator> iterator;
+
using singleton<FIFORunner>::instance;
using singleton<FIFORunner>::alive;
unsigned hangCount() const;
+ iterator begin() const;
+ iterator end() const;
+
protected:
private:
prefix_ char const * senf::scheduler::SignalEvent::v_type()
const
{
- return "signal";
+ return "si";
}
prefix_ std::string senf::scheduler::SignalEvent::v_info()
prefix_ char const * senf::scheduler::TimerEvent::v_type()
const
{
- return "timer";
+ return "tm";
}
prefix_ std::string senf::scheduler::TimerEvent::v_info()