X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FFdEvent.hh;h=1c058780b97ce811141c0634b745e67a75d85f4c;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=2a494890fca33df6367dbeb97101c236ea6e8a1c;hpb=04b5fd6be72efd504de15a215a268f8b82f4d132;p=senf.git diff --git a/Scheduler/FdEvent.hh b/Scheduler/FdEvent.hh index 2a49489..1c05878 100644 --- a/Scheduler/FdEvent.hh +++ b/Scheduler/FdEvent.hh @@ -23,8 +23,8 @@ /** \file \brief FdDispatcher public header */ -#ifndef HH_FdDispatcher_ -#define HH_FdDispatcher_ 1 +#ifndef HH_SENF_Scheduler_FdEvent_ +#define HH_SENF_Scheduler_FdEvent_ 1 // Custom includes #include "../boost/intrusive/iset_hook.hpp" @@ -39,8 +39,8 @@ namespace senf { namespace scheduler { namespace detail { - struct FdSetTag; - typedef boost::intrusive::iset_base_hook FdSetBase; + struct FdSetTag; + typedef boost::intrusive::iset_base_hook FdSetBase; struct FdSetCompare; struct FindFd; class FdDispatcher; @@ -75,31 +75,31 @@ namespace scheduler { handles are provided. The FdEvent class is an implementation of the RAII idiom: The event will be automatically - unregistered in the FdEvent destructor. The TimerEvent instance should be created - within the same scope or on a scope below where the callback is defined (e.g. if the - callback is a member function it should be defined as a class member). + unregistered in the FdEvent destructor. The FdEvent instance should be created within the + same scope or on a scope below where the callback is defined (e.g. if the callback is a + member function it should be defined as a class member). */ class FdEvent - : public detail::FIFORunner::TaskInfo, - public detail::FdSetBase, - public detail::FdManager::Event + : public detail::FIFORunner::TaskInfo, + public detail::FdSetBase, + public detail::FdManager::Event { public: /////////////////////////////////////////////////////////////////////////// // Types - typedef boost::function Callback; + typedef boost::function Callback; enum Events { - EV_NONE = 0 ///< No event - , EV_READ = detail::FdManager::EV_READ ///< fd readable (or EOF) - , EV_PRIO = detail::FdManager::EV_PRIO, ///< OOB data available for read - , EV_WRITE = detail::FdManager::EV_WRITE ///< fd writable - , EV_HUP = detail::FdManager::EV_HUP ///< remote end closed connection - , EV_ERR = detail::FdManager::EV_ERR ///< transport error + EV_NONE = 0 ///< No event + , EV_READ = detail::FdManager::EV_READ ///< fd readable (or EOF) + , EV_PRIO = detail::FdManager::EV_PRIO ///< OOB data available for read + , EV_WRITE = detail::FdManager::EV_WRITE ///< fd writable + , EV_HUP = detail::FdManager::EV_HUP ///< remote end closed connection + , EV_ERR = detail::FdManager::EV_ERR ///< transport error , EV_ALL = (detail::FdManager::EV_READ | detail::FdManager::EV_WRITE - | detail::FdManager::EV_PRIO) ///< register all events + | detail::FdManager::EV_PRIO) ///< register all events (read, prio and write) }; /////////////////////////////////////////////////////////////////////////// @@ -107,8 +107,8 @@ namespace scheduler { ///@{ template - FdEvent(std::string const & name, Callback const & cb, Handle const & handle, int events, - bool initiallyEnabled = true); + FdEvent(std::string const & name, Callback const & cb, Handle const & handle, int events, + bool initiallyEnabled = true); ///< Register a file descriptor event /**< Registers \a cb to be called when any of the \a events occurs on \a handle. If \a initiallyEnabled is set \c @@ -131,18 +131,17 @@ namespace scheduler { \param[in] cb Callback to call. This callback may \e explicitly be set to \c 0 if the value cannot be initialized. */ - ~FdEvent(); + ~FdEvent(); ///@} /////////////////////////////////////////////////////////////////////////// - void disable(); ///< Disable event - void enable(); ///< Enable event - bool enabled(); ///< \c true if event enabled, \c false otherwise + void disable(); ///< Disable event + void enable(); ///< Enable event - FdEvent & action(Callback const & cb); ///< Change event callback + FdEvent & action(Callback const & cb); ///< Change event callback - FdEvent & events(int events); ///< Change event mask + FdEvent & events(int events); ///< Change event mask FdEvent & addEvents(int events); ///< Add additional events to event mask FdEvent & removeEvents(int events); ///< Remove events from event mask int events(); ///< Current event mask @@ -156,14 +155,16 @@ namespace scheduler { protected: private: - virtual void signal(int events); - virtual void run(); + virtual void signal(int events); + virtual void v_run(); + virtual char const * v_type() const; + virtual std::string v_info() const; - Callback cb_; - int fd_; + Callback cb_; + int fd_; bool pollable_; - int events_; - int signaledEvents_; + int events_; + int signaledEvents_; friend class detail::FdSetCompare; friend class detail::FindFd; @@ -171,8 +172,14 @@ namespace scheduler { friend class detail::FileDispatcher; }; - int retrieve_filehandle(int fd); + /** \brief Get file descriptor from handle object + This function will query the \a handle for it's file descriptor. The real implementation + must be provided by a freestanding function \c retrieve_filehandle(Handle const & h) within + the namespace of \a Handle. + */ + template + int get_descriptor(Handle const & handle); }} ///////////////////////////////hh.e////////////////////////////////////////