4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief FdManager public header */
27 #define HH_FdManager_ 1
31 #include "ClockService.hh"
33 //#include "FdManager.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
39 /** \brief Manage file descriptor event processing
41 The FdManager is the internal class which manages all events (all events need to somehow be
42 made accessible via a file descriptor). File descriptors are added or removed from the
43 FdManager which then allows waiting until an event occurs on one of the descriptors.
45 Registered events must be derived from FdManager::Event. The FdManager does \e not manage
46 the event classes, it just manages pointers to externally owned events (the events are owned
47 by the respective dispatchers).
49 When an event is posted, it's \c signal() member is called. However, this call will \e not
50 execute the user callback registered for the event, it will just mark the relevant tasks as
58 ///////////////////////////////////////////////////////////////////////////
64 virtual void signal(int events) = 0; ///< Called when the given event is posted
68 EV_READ = Poller<Event>::EV_READ, EV_PRIO = Poller<Event>::EV_PRIO, EV_WRITE = Poller<Event>::EV_WRITE,
69 EV_HUP = Poller<Event>::EV_HUP, EV_ERR = Poller<Event>::EV_ERR
72 ///////////////////////////////////////////////////////////////////////////
73 ///\name Structors and default members
79 ///////////////////////////////////////////////////////////////////////////
81 bool set(int fd, int events, Event * entry); ///< Set file descriptor event mask
82 /**< This sets the event mask for \a fd to \a events which
83 is a combination of values from the \c Events enum. If
84 \a fd is already registered, the registration is
85 changed to conform to the parameters passed, otherwise
86 a new registration is added.
87 \param[in] fd file descriptor
88 \param[in] events events to register for
89 \param[in] entry event to signal
90 \returns \c true, if \a fd supports polling, \c false
92 void remove(int fd); ///< Remove \a fd from the manager
94 void timeout(int t); ///< Set event timeout
95 /**< proceseOnce() will wait for max \a t milliseconds for
96 an event to occur. If set to -1, processOnce() will
98 int timeout() const; ///< Get timeout in milliseconds
100 void processOnce(); ///< Wait for events
101 /**< This call waits until at least one event is posted but
102 no longer than the current timeout(). */
104 ClockService::clock_type eventTime() const; ///< Time of last event
109 Poller<Event> poller_;
110 senf::ClockService::clock_type eventTime_;
115 ///////////////////////////////hh.e////////////////////////////////////////
116 #include "FdManager.cci"
117 //#include "FdManager.ct"
118 //#include "FdManager.cti"
125 // comment-column: 40
126 // c-file-style: "senf"
127 // indent-tabs-mode: nil
128 // ispell-local-dictionary: "american"
129 // compile-command: "scons -u test"