- updated MPESection creation
[senf.git] / Scheduler / Scheduler.hh
index 5f0f635..b320e77 100644 (file)
@@ -72,8 +72,12 @@ namespace senf {
         If you need to pass additional information to your handler, use <a
         href="http://www.boost.org/libs/bind/bind.html">Boost.Bind</a>:
         \code
+        // Handle callback function
+        void callback(UDPv4ClientSocketHandle handle, senf::Scheduler::EventId event) {..}
         // Pass 'handle' as additional first argument to callback()
-        Scheduler::instance().add(handle, boost::bind(&callback, handle, _1))
+        Scheduler::instance().add(handle, boost::bind(&callback, handle, _1), EV_READ)
+         // Timeout function
+        void timeout( int n) {..}
         // Call timeout() handler with argument 'n'
         Scheduler::instance().timeout(boost::bind(&timeout, n))
         \endcode
@@ -82,7 +86,7 @@ namespace senf {
         href="http://www.boost.org/libs/bind/bind.html">Boost.Bind</a> or senf::membind()
         \code
         // e.g. in Foo::Foo() constructor:
-        Scheduler::instance().add(handle_, senf::membind(&Foo::callback, this))
+        Scheduler::instance().add(handle_, senf::membind(&Foo::callback, this)), EV_READ)
         \endcode
         
 
@@ -90,7 +94,7 @@ namespace senf {
         
         File descriptors are managed using add() or remove()
         \code
-        Scheduler::instance().add(handle, &callback);
+        Scheduler::instance().add(handle, &callback, EV_ALL);
         Scheduler::instance().remove(handle);
         \endcode 
 
@@ -167,11 +171,23 @@ namespace senf {
         ///////////////////////////////////////////////////////////////////////////
         // Types
 
-        /** \brief Types of file descriptor events */
-        enum EventId { EV_NONE=0,
-                       EV_READ=1, EV_PRIO=2, EV_WRITE=4, 
-                       EV_ALL=7,
-                       EV_HUP=8, EV_ERR=16 };
+        /** \brief Types of file descriptor events 
+
+            These events are grouped into to classes:
+            \li Ordinary file descriptor events for which handlers may be registered. These are
+                EV_READ, EV_PRIO and EV_WRITE. EV_ALL is a combination of these three.
+            \li Error flags. These additional flags may be passed to a handler to pass an error
+                condition to the handler. 
+         */
+        enum EventId { 
+            EV_NONE  =  0   /**< No event */
+          , EV_READ  =  1   /**< File descriptor is readable */
+          , EV_PRIO  =  2   /**< File descriptor has OOB data */
+          , EV_WRITE =  4   /**< File descriptor is writable */
+          , EV_ALL   =  7   /**< Used to register all events at once (read/prio/write) */
+          , EV_HUP   =  8   /**< Hangup condition on file handle */
+          , EV_ERR   = 16   /**< Error condition on file handle */
+        };
 
         /** \brief Template typedef for Callback type
 
@@ -234,7 +250,8 @@ namespace senf {
                                                  the Handle interface defined above.
                                              \param[in] cb callback
                                              \param[in] eventMask arbitrary combination via '|'
-                                                 operator of EventId designators. */
+                                                 operator of \ref senf::Scheduler::EventId "EventId"
+                                                 designators. */
         template <class Handle>
         void remove(Handle const & handle, int eventMask = EV_ALL); ///< Remove event callback
                                         /**< remove() will remove any callback registered for any of
@@ -243,8 +260,8 @@ namespace senf {
                                              \param[in] handle file descriptor or handle providing
                                                  the Handle interface defined above.
                                              \param[in] eventMask arbitrary combination via '|'
-                                                 operator of EventId designators. */
-
+                                                 operator of \ref senf::Scheduler::EventId "EventId"
+                                                 designators. */
         ///\}
 
         ///\name Timeouts
@@ -283,9 +300,9 @@ namespace senf {
                                         ///< Remove signal handler for \a signal
 
         /// The signal number passed to registerSignal or unregisterSignal is invalid
-        struct InvalidSignalNumberException : public std::exception
-        { virtual char const * what() const throw() 
-                { return "senf::Scheduler::InvalidSignalNumberException"; } };
+        struct InvalidSignalNumberException : public senf::Exception
+        { InvalidSignalNumberException() 
+              : senf::Exception("senf::Scheduler::InvalidSignalNumberException"){} };
 
 
         ///\}