Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Scheduler / FdEvent.ih
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief FdDispatcher internal header */
25
26 #ifndef IH_SENF_Scheduler_FdEvent_
27 #define IH_SENF_Scheduler_FdEvent_ 1
28
29 // Custom includes
30 #include <senf/boost_intrusive/iset.hpp>
31
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 namespace senf {
35 namespace scheduler {
36
37     void restart();
38
39 namespace detail {
40
41     struct FdSetCompare {
42         bool operator()(FdEvent const & a, FdEvent const & b) const
43         { return a.fd_ < b.fd_; }
44     };
45
46     struct FindFd {
47         bool operator()(FdEvent const & a, int b) const
48         { return a.fd_ < b; }
49         bool operator()(int a, FdEvent const & b) const
50         { return a < b.fd_; }
51     };
52
53     class FdDispatcher
54         : public senf::singleton<FdDispatcher>
55     {
56     public:
57         using senf::singleton<FdDispatcher>::instance;
58         using senf::singleton<FdDispatcher>::alive;
59
60         bool add(FdEvent & event);
61         void remove(FdEvent & event);
62
63         bool empty() const;
64
65     protected:
66
67     private:
68         FdDispatcher();
69         ~FdDispatcher();
70
71         typedef boost::intrusive::imultiset< FdSetBase::value_traits<FdEvent>,
72                                              FdSetCompare,
73                                              false > FdSet;
74
75         FdSet fds_;
76
77         friend void senf::scheduler::restart();
78         friend class singleton<FdDispatcher>;
79         friend class senf::scheduler::FdEvent;
80     };
81
82     class FileDispatcher
83         : public senf::singleton<FileDispatcher>
84     {
85     public:
86         using senf::singleton<FileDispatcher>::instance;
87         using senf::singleton<FileDispatcher>::alive;
88
89         void add(FdEvent & event);
90         void remove(FdEvent & event);
91
92         void prepareRun();
93
94         // Called by IdleEventDispatcher
95         void timeout(int t);
96         int timeout() const;
97
98         bool empty() const;
99
100     protected:
101
102     private:
103         FileDispatcher();
104         ~FileDispatcher();
105
106         // We really only need a list here but we need to use the same event structure used by
107         // the FdEvent.
108         typedef boost::intrusive::imultiset< FdSetBase::value_traits<FdEvent>,
109                                              FdSetCompare,
110                                              false > FdSet;
111
112         FdSet fds_;
113         int managerTimeout_;
114
115         friend void senf::scheduler::restart();
116         friend class singleton<FileDispatcher>;
117     };
118
119     template <class Handle>
120     int get_descriptor(Handle const & handle);
121
122     int retrieve_filehandle(int fd);
123
124 }}}
125
126 //-/////////////////////////////////////////////////////////////////////////////////////////////////
127 #endif
128
129 \f
130 // Local Variables:
131 // mode: c++
132 // fill-column: 100
133 // comment-column: 40
134 // c-file-style: "senf"
135 // indent-tabs-mode: nil
136 // ispell-local-dictionary: "american"
137 // compile-command: "scons -u test"
138 // End: