X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FFIFORunner.hh;h=40154d38f23a29834c95780d7b8690eeb277d4b2;hb=a634d4df375e12f0a9dcd0014f1ee14b70de16b8;hp=3ad8d7e1850380d33531951f5e5708698f0ebca8;hpb=919e588a2c387c9a910aa8761e65155a0d205bba;p=senf.git diff --git a/Scheduler/FIFORunner.hh b/Scheduler/FIFORunner.hh index 3ad8d7e..40154d3 100644 --- a/Scheduler/FIFORunner.hh +++ b/Scheduler/FIFORunner.hh @@ -27,9 +27,12 @@ #define HH_FIFORunner_ 1 // Custom includes +#include #include #include "../boost/intrusive/ilist.hpp" #include "../boost/intrusive/ilist_hook.hpp" +#include "../Utils/singleton.hh" +#include "EventManager.hh" //#include "FIFORunner.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -37,10 +40,12 @@ namespace senf { namespace scheduler { - /** \brief - */ + void restart(); + +namespace detail { + class FIFORunner - : boost::noncopyable + : public singleton { public: struct TaskInfo; @@ -48,46 +53,79 @@ namespace scheduler { private: struct TaskListTag; typedef boost::intrusive::ilist_base_hook TaskListBase; - typedef TaskListBase::value_traits TaskListType; - typedef boost::intrusive::ilist TaskList; + typedef boost::intrusive::ilist, false> TaskList; public: - /////////////////////////////////////////////////////////////////////////// - // Types - - struct TaskInfo - : public TaskListBase + class TaskInfo + : public Event, + public TaskListBase { - TaskInfo(); + public: + explicit TaskInfo(std::string const & name); virtual ~TaskInfo(); - bool runnable; - virtual void run() = 0; - }; + void run(); - /////////////////////////////////////////////////////////////////////////// - ///\name Structors and default members - ///@{ + bool runnable() const; - FIFORunner(); + protected: + void setRunnable(); + + private: + virtual void v_run() = 0; + virtual bool v_enabled() const; + + bool runnable_; +# ifdef SENF_DEBUG + std::string backtrace_; +# endif + + friend class FIFORunner; + }; - ///@} - /////////////////////////////////////////////////////////////////////////// + typedef boost::filter_iterator< + EventManager::IteratorFilter, TaskList::const_iterator> iterator; + + using singleton::instance; + using singleton::alive; void enqueue(TaskInfo * task); void dequeue(TaskInfo * task); void run(); + void taskTimeout(unsigned ms); + unsigned taskTimeout() const; + + unsigned hangCount() const; + + iterator begin() const; + iterator end() const; + protected: private: + FIFORunner(); + ~FIFORunner(); + + static void watchdog(int, siginfo_t *, void *); + TaskList tasks_; TaskList::iterator next_; + timer_t watchdogId_; + unsigned watchdogMs_; + std::string runningName_; +# ifdef SENF_DEBUG + std::string runningBacktrace_; +# endif + unsigned watchdogCount_; + unsigned hangCount_; + + friend void senf::scheduler::restart(); + friend class singleton; }; - -}} +}}} ///////////////////////////////hh.e//////////////////////////////////////// #include "FIFORunner.cci"