X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FFIFORunner.hh;h=a6db0a5cb81724883110a1eca612ccffc41f595c;hb=23ef68f7c443f0993b2b46cd912666c040fdccba;hp=756f07fc4db38f98536ec8d3778f95c95ff6bc50;hpb=925317c7f45c32b01ab9292023db3f372b74bf0f;p=senf.git diff --git a/Scheduler/FIFORunner.hh b/Scheduler/FIFORunner.hh index 756f07f..a6db0a5 100644 --- a/Scheduler/FIFORunner.hh +++ b/Scheduler/FIFORunner.hh @@ -37,20 +37,12 @@ ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - - class Scheduler; - namespace scheduler { - /** \brief Task execution scheduler + void restart(); - The FIFORunner implements a simple FIFO scheduler for callback tasks. All tasks are held in - a queue. Whenever a task is run, it is moved to the end of the queue. Running the queue will - run all tasks which have been marked runnable. +namespace detail { - When running a task, it's runnable flag is always reset. The flag is set whenever an event - is posted for the task. - */ class FIFORunner : public singleton { @@ -63,48 +55,37 @@ namespace scheduler { typedef boost::intrusive::ilist, false> TaskList; public: - /////////////////////////////////////////////////////////////////////////// - // Types - - /** \brief Task structure - - 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 - }; - - /////////////////////////////////////////////////////////////////////////// - ///\name Structors and default members - ///@{ + friend class FIFORunner; + }; using singleton::instance; using singleton::alive; - ///@} - /////////////////////////////////////////////////////////////////////////// - - void enqueue(TaskInfo * task); ///< Add task to queue - void dequeue(TaskInfo * task); ///< Remove task from queue + void enqueue(TaskInfo * task); + void dequeue(TaskInfo * task); - void run(); ///< Run queue + void run(); - void taskTimeout(unsigned ms); ///< Set task timeout to \a ms milliseconds - unsigned taskTimeout() const; ///< Get task timeout in milliseconds + void taskTimeout(unsigned ms); + unsigned taskTimeout() const; unsigned hangCount() const; ///< Number of task expirations /**< The FIFORunner manages a watchdog which checks, that a @@ -131,12 +112,11 @@ namespace scheduler { unsigned watchdogCount_; unsigned hangCount_; + friend void senf::scheduler::restart(); friend class singleton; - friend class senf::Scheduler; }; - -}} +}}} ///////////////////////////////hh.e//////////////////////////////////////// #include "FIFORunner.cci"