// Custom includes
#include "../Utils/Logger/SenfLog.hh"
-#include "FdDispatcher.hh"
-#include "TimerDispatcher.hh"
-#include "SignalDispatcher.hh"
-#include "FileDispatcher.hh"
+#include "FdEvent.hh"
+#include "TimerEvent.hh"
+#include "SignalEvent.hh"
#include "../Utils/Logger/SenfLog.hh"
//#include "scheduler.mpp"
/** \brief Callback type for signal events */
typedef boost::function<void (siginfo_t const &)> SignalCallback;
- /** \brief Timer id type */
- typedef scheduler::TimerDispatcher::timer_id timer_id;
-
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
///@}
///////////////////////////////////////////////////////////////////////////
- ///\name File Descriptors
- ///\{
-
- template <class Handle>
- void add(std::string const & name, Handle const & handle, FdCallback const & cb,
- int eventMask = EV_ALL); ///< Add file handle event callback
- /**< add() will add a callback to the %scheduler. The
- callback will be called for the given type of event on
- the given arbitrary file-descriptor or
- handle-like object. If there already is a Callback
- registered for one of the events requested, the new
- handler will replace the old one.
- \param[in] name descriptive name to identify the
- callback.
- \param[in] handle file descriptor or handle providing
- the Handle interface defined above.
- \param[in] cb callback
- \param[in] eventMask arbitrary combination via '|'
- operator of \ref senf::Scheduler::EventId "EventId"
- designators. */
-
- template <class Handle>
- void add(Handle const & handle, FdCallback const & cb,
- int eventMask = EV_ALL); ///< Add file handle event callback
- /**< \see add() */
-
-
- template <class Handle>
- void remove(Handle const & handle, int eventMask = EV_ALL); ///< Remove event callback
- /**< remove() will remove any callback registered for any of
- the given events on the given file descriptor or handle
- like object.
- \param[in] handle file descriptor or handle providing
- the Handle interface defined above.
- \param[in] eventMask arbitrary combination via '|'
- operator of \ref senf::Scheduler::EventId "EventId"
- designators. */
-
- ///\}
-
- ///\name Timeouts
- ///\{
-
- timer_id timeout(std::string const & name, ClockService::clock_type timeout,
- SimpleCallback const & cb);
- ///< Add timeout event
- /**< \returns timer id
- \param[in] name descriptive name to identify the
- callback.
- \param[in] timeout timeout in nanoseconds
- \param[in] cb callback to call after \a timeout
- milliseconds */
-
- timer_id timeout(ClockService::clock_type timeout, SimpleCallback const & cb);
- ///< Add timeout event
- /**< \see timeout() */
-
- void cancelTimeout(timer_id id); ///< Cancel timeout \a id
-
-#ifndef DOXYGEN
- ClockService::clock_type timeoutEarly() const;
- void timeoutEarly(ClockService::clock_type v);
-
- ClockService::clock_type timeoutAdjust() const;
- void timeoutAdjust(ClockService::clock_type v);
-#endif
-
- ///\}
-
- ///\name Signal handlers
- ///\{
-
- void registerSignal(unsigned signal, SignalCallback const & cb);
- ///< Add signal handler
- /**< \param[in] signal signal number to register handler for
- \param[in] cb callback to call whenever \a signal is
- delivered. */
-
- void unregisterSignal(unsigned signal);
- ///< Remove signal handler for \a signal
-
- ///\}
-
void process(); ///< Event handler main loop
/**< This member must be called at some time to enter the
event handler main loop. Only while this function is
unsigned taskTimeout() const;
unsigned hangCount() const;
+ void restart();
+
protected:
private:
Scheduler();
- void do_add(int fd, FdCallback const & cb, int eventMask = EV_ALL);
- void do_add(std::string const & name, int fd, FdCallback const & cb,
- int eventMask = EV_ALL);
- void do_remove(int fd, int eventMask);
-
bool terminate_;
- scheduler::FdManager manager_;
- scheduler::FIFORunner runner_;
-
- scheduler::FdDispatcher fdDispatcher_;
- scheduler::TimerDispatcher timerDispatcher_;
- scheduler::SignalDispatcher signalDispatcher_;
- scheduler::FileDispatcher fileDispatcher_;
};
- /** \brief Default file descriptor accessor
-
- retrieve_filehandle() provides the %scheduler with support for explicit file descriptors as
- file handle argument.
-
- \relates Scheduler
- */
- int retrieve_filehandle(int fd);
-
/** \brief %scheduler specific time source for Utils/Logger framework
This time source may be used to provide timing information for log messages within the
///////////////////////////////hh.e////////////////////////////////////////
#include "Scheduler.cci"
//#include "Scheduler.ct"
-#include "Scheduler.cti"
+//#include "Scheduler.cti"
#endif
\f