/** \file
\brief FIFORunner public header */
-#ifndef HH_FIFORunner_
-#define HH_FIFORunner_ 1
+#ifndef HH_SENF_Scheduler_FIFORunner_
+#define HH_SENF_Scheduler_FIFORunner_ 1
// Custom includes
#include <signal.h>
public TaskListBase
{
public:
- explicit TaskInfo(std::string const & name);
+ enum Priority { PRIORITY_LOW = 0, PRIORITY_NORMAL = 1, PRIORITY_HIGH = 2 };
+
+ explicit TaskInfo(std::string const & name, Priority priority=PRIORITY_NORMAL);
virtual ~TaskInfo();
void run();
+ bool runnable() const;
+
protected:
void setRunnable();
virtual bool v_enabled() const;
bool runnable_;
+ Priority priority_;
# ifdef SENF_DEBUG
std::string backtrace_;
# endif
friend class FIFORunner;
};
+ typedef boost::filter_iterator<
+ EventManager::IteratorFilter, TaskList::const_iterator> iterator;
+
using singleton<FIFORunner>::instance;
using singleton<FIFORunner>::alive;
void taskTimeout(unsigned ms);
unsigned taskTimeout() const;
+ void startWatchdog();
+ void stopWatchdog();
+
unsigned hangCount() const;
+ iterator begin() const;
+ iterator end() const;
+
protected:
private:
static void watchdog(int, siginfo_t *, void *);
+ TaskList::iterator priorityEnd(TaskInfo::Priority p);
+ void run(TaskList::iterator f, TaskList::iterator l);
+
+ struct NullTask : public TaskInfo
+ {
+ NullTask();
+ ~NullTask();
+ virtual void v_run();;
+ virtual char const * v_type() const;
+ virtual std::string v_info() const;
+ };
+
TaskList tasks_;
TaskList::iterator next_;
+
+ NullTask normalPriorityEnd_;
+ NullTask highPriorityEnd_;
+
timer_t watchdogId_;
+ bool watchdogRunning_;
unsigned watchdogMs_;
std::string runningName_;
# ifdef SENF_DEBUG