X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FFIFORunner.hh;h=3887a3d3506e481fc0c1713db50dc2a5e5163a44;hb=03516e8371a90f908ce54dedb3c874eec7dd08ff;hp=9121445fecb097c6045c6eeb937ff3dbd910e2fe;hpb=40fa3e3f1e0f639c68bd15bf469e35045f94abee;p=senf.git diff --git a/Scheduler/FIFORunner.hh b/Scheduler/FIFORunner.hh index 9121445..3887a3d 100644 --- a/Scheduler/FIFORunner.hh +++ b/Scheduler/FIFORunner.hh @@ -31,11 +31,15 @@ #include #include "../boost/intrusive/ilist.hpp" #include "../boost/intrusive/ilist_hook.hpp" +#include "../Utils/singleton.hh" //#include "FIFORunner.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { + + class Scheduler; + namespace scheduler { /** \brief Task execution scheduler @@ -48,7 +52,7 @@ namespace scheduler { is posted for the task. */ class FIFORunner - : boost::noncopyable + : public singleton { public: struct TaskInfo; @@ -56,8 +60,7 @@ 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: /////////////////////////////////////////////////////////////////////////// @@ -67,30 +70,34 @@ namespace scheduler { TaskInfo is the base-class for all tasks. */ - struct TaskInfo + class TaskInfo : public TaskListBase { - TaskInfo(); + public: + explicit TaskInfo(std::string const & name); virtual ~TaskInfo(); - bool runnable; ///< Runnable flag - /**< This must be set to \c true when the task is - runnable. It is reset automatically when the task is - run. */ + protected: + void setRunnable(); + + private: + virtual void run() = 0; - std::string name; ///< Descriptive task name + bool runnable_; + std::string name_; # ifdef SENF_DEBUG - std::string backtrace; + std::string backtrace_; # endif - virtual void run() = 0; ///< Called to run the task + + friend class FIFORunner; }; /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ - FIFORunner(); - ~FIFORunner(); + using singleton::instance; + using singleton::alive; ///@} /////////////////////////////////////////////////////////////////////////// @@ -100,6 +107,9 @@ namespace scheduler { void run(); ///< Run queue + void taskTimeout(unsigned ms); ///< Set task timeout to \a ms milliseconds + unsigned taskTimeout() const; ///< Get task timeout in milliseconds + unsigned hangCount() const; ///< Number of task expirations /**< The FIFORunner manages a watchdog which checks, that a single task does not run continuously for a longer time @@ -109,18 +119,25 @@ namespace scheduler { protected: private: + FIFORunner(); + ~FIFORunner(); + static void watchdog(int, siginfo_t *, void *); TaskList tasks_; TaskList::iterator next_; - int watchdogId_; + timer_t watchdogId_; + unsigned watchdogMs_; std::string runningName_; # ifdef SENF_DEBUG std::string runningBacktrace_; # endif + unsigned watchdogCount_; unsigned hangCount_; - }; + friend class singleton; + friend class senf::Scheduler; + }; }}