X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FFIFORunner.hh;h=39e2e3a6a8801d4ce5a163aa4df6347395008b84;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=49d62fa9dbda3005a14bc04fd3f8f9ff73f2ca29;hpb=2da517bbcdb2af10d2322fc762ca27774b53b435;p=senf.git diff --git a/Scheduler/FIFORunner.hh b/Scheduler/FIFORunner.hh index 49d62fa..39e2e3a 100644 --- a/Scheduler/FIFORunner.hh +++ b/Scheduler/FIFORunner.hh @@ -23,8 +23,8 @@ /** \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 @@ -61,11 +61,15 @@ namespace detail { 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(); @@ -74,6 +78,7 @@ namespace detail { virtual bool v_enabled() const; bool runnable_; + Priority priority_; # ifdef SENF_DEBUG std::string backtrace_; # endif @@ -81,6 +86,9 @@ namespace detail { friend class FIFORunner; }; + typedef boost::filter_iterator< + EventManager::IteratorFilter, TaskList::const_iterator> iterator; + using singleton::instance; using singleton::alive; @@ -91,8 +99,16 @@ namespace detail { void taskTimeout(unsigned ms); unsigned taskTimeout() const; + void abortOnTimeout(bool flag); + bool abortOnTimeout() const; - unsigned hangCount() const; + void startWatchdog(); + void stopWatchdog(); + + unsigned hangCount(); + + iterator begin() const; + iterator end() const; protected: @@ -102,10 +118,28 @@ namespace detail { 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_; + bool watchdogAbort_; std::string runningName_; # ifdef SENF_DEBUG std::string runningBacktrace_;