X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FScheduler%2FScheduler.hh;h=6ecef0d63203409d93e3f8580b1acc2829883b0b;hb=84f14a42f9993e186c7897ce0db021300e0a2d48;hp=f83a8d0e4a245298da82aea4bf7f650aef413665;hpb=8ee8742d5bcf846e0ebeb2abf994e371142b7707;p=senf.git diff --git a/senf/Scheduler/Scheduler.hh b/senf/Scheduler/Scheduler.hh index f83a8d0..6ecef0d 100644 --- a/senf/Scheduler/Scheduler.hh +++ b/senf/Scheduler/Scheduler.hh @@ -80,7 +80,7 @@ namespace senf { public: SomeServer(SomeSocketHandle handle) - : handle_ (handle), + : handle_ (handle), event_ ("SomeServer handler", senf::membind(&SomeServer::readData, this), handle, senf::scheduler::FdEvent::EV_READ) {} @@ -105,17 +105,17 @@ namespace senf { \section sched_handlers Specifying handlers All handlers are specified as generic Boost.Function objects. This allows to - pass any callable as a handler. Depending on the type of handler, some additional arguments may - be passed to the handler by the %scheduler. + href="http://www.boost.org/doc/libs/release/libs/functional/index.html">Boost.Function + objects. This allows to pass any callable as a handler. Depending on the type of handler, + some additional arguments may be passed to the handler by the %scheduler. If you need to pass additional information to your handler, use Boost.Bind: + href="http://www.boost.org/doc/libs/release/libs/bind/bind.html">Boost.Bind: \code // Handle callback function void callback(UDPv4ClientSocketHandle handle, senf::Scheduler::EventId event) {..} // Pass 'handle' as additional first argument to callback() - senf::scheduler::FdEvent event ("name", boost::bind(&callback, handle, _1), + senf::scheduler::FdEvent event ("name", boost::bind(&callback, handle, _1), handle, senf::scheduler::FdEvent::EV_READ); // Timeout function void timeout( int n) {..} @@ -125,12 +125,12 @@ namespace senf { \endcode To use member-functions as callbacks, use either Boost.Bind or senf::membind() + href="http://www.boost.org/doc/libs/release/libs/bind/bind.html">Boost.Bind or senf::membind() \code // e.g. in Foo::Foo() constructor: Foo::Foo() : handle_ (...), - readevent_ ("Foo read", senf::membind(&Foo::callback, this), + readevent_ ("Foo read", senf::membind(&Foo::callback, this), handle_, senf::scheduler::FdEvent::EV_READ) { ... } \endcode @@ -142,7 +142,7 @@ namespace senf { \section sched_exec Executing the Scheduler To enter the scheduler main-loop, call - + \code senf::scheduler::process(); \endcode @@ -163,15 +163,15 @@ namespace senf { \code #include #include - + class Foo { public: void add(int fd) { fdEvents.insert( - fd, - new senf::scheduler::FdEvent("foo", boost::bind(&callback, this, fd, _1), fd, + fd, + new senf::scheduler::FdEvent("foo", boost::bind(&callback, this, fd, _1), fd, senf::scheduler::FdEvent::EV_READ) ); } @@ -194,7 +194,7 @@ namespace senf { container API. The only difference is, that all elements added to the container \e must be created via \c new and that the pointer containers themselves are \e not copyable (ok, they are, if the elements are cloneable ...). See Boost.PointerContainer + href="http://www.boost.org/doc/libs/release/libs/ptr_container/doc/ptr_container.html">Boost.PointerContainer for the pointer container library reference. @@ -207,7 +207,7 @@ namespace senf { can produce an informative message and optionally the program can be aborted. The watchdog is controlled using the watchdogTimeout(), watchdogEvents() and watchdogAbort(). - functions. + functions. The watchdog is implemented using a free running interval timer. The watchdog signal (\c SIGURG) must \e not be blocked. If signals need to be blocked for some reason, those regions will not be @@ -227,13 +227,13 @@ namespace senf { */ namespace scheduler { - /** \brief Event handler main loop - + /** \brief Event handler main loop + This member must be called at some time to enter the event handler main loop. Only while this function is running any events are handled. The call will return if \li a callback calls terminate() - \li the run queue becomes empty. - */ + \li the run queue becomes empty. + */ void process(); /** \brief \c true, if scheduler is running, \c false otherwise */ @@ -242,9 +242,9 @@ namespace scheduler { /** \brief Called by callbacks to terminate the main loop This member may be called by any callback to tell the main loop to terminate. The main loop - will return to it's caller after the currently running callback returns. + will return to it's caller after the currently running callback returns. */ - void terminate(); + void terminate(); /** \brief Immediately rescheduler @@ -256,9 +256,9 @@ namespace scheduler { /** \brief Return timestamp of last event This is the timestamp, the last event has been signaled. This is the real time at which the - event is delivered \e not the time it should have been delivered (in the case of timers). + event is delivered \e not the time it should have been delivered (in the case of timers). */ - ClockService::clock_type eventTime(); + ClockService::clock_type eventTime(); /** \brief Return (approximate) current time @@ -270,22 +270,22 @@ namespace scheduler { ClockService::clock_type now(); /** \brief Set watchdog timeout to \a ms milliseconds. - + Setting the watchdog timeout to 0 will disable the watchdog. */ - void watchdogTimeout(unsigned ms); + void watchdogTimeout(unsigned ms); /** \brief Current watchdog timeout in milliseconds */ - unsigned watchdogTimeout(); + unsigned watchdogTimeout(); - /** \brief Number of watchdog events + /** \brief Number of watchdog events calling watchtogEvents() will reset the counter to 0 */ - unsigned watchdogEvents(); + unsigned watchdogEvents(); /** \brief Enable/disable abort on watchdog event. - + Calling watchdogAbort(\c true) will enable aborting the program execution on a watchdog event. */ @@ -295,7 +295,7 @@ namespace scheduler { bool watchdogAbort(); /** \brief Switch to using hi resolution timers - + By default, timers are implemented directly using epoll. This however restricts the timer resolution to that of the kernel HZ value. @@ -325,12 +325,12 @@ namespace scheduler { bool usingHiresTimers(); /** \brief Restart scheduler - + This call will restart all scheduler dispatchers (timers, signals, file descriptors). This is necessary after a fork(). \warning This call will \e remove all registered events from the scheduler */ - void restart(); + void restart(); /** \brief Return \c true, if no event is registered, \c false otherwise. */ bool empty(); @@ -356,7 +356,7 @@ namespace scheduler { /** \brief Temporarily block all signals This class is used to temporarily block all signals in a critical section. - + \code // Begin critical section { @@ -379,7 +379,7 @@ namespace scheduler { /**< \param[in] initiallyBlocked set to \c false to not automatically block signals initially */ ~BlockSignals(); ///< Release all signal blocks - + void block(); ///< Block signals if not blocked void unblock(); ///< Unblock signals if blocked bool blocked() const; ///< \c true, if signals currently blocked, \c false