8b6472267d8562cb5df8b28c0cbe5e869e0b09bb
[senf.git] / senf / Scheduler / FdEvent.cci
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 inline non-template implementation */
25
26 #include "FdEvent.ih"
27
28 // Custom includes
29 #include "FdManager.hh"
30
31 #define prefix_ inline
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35 // senf::scheduler::FdEvent
36
37 prefix_ senf::scheduler::FdEvent::FdEvent(std::string const & name, Callback const & cb)
38     : detail::FIFORunner::TaskInfo (name), cb_ (cb), fd_ (-1), pollable_ (true), events_ (0)
39 {}
40
41 prefix_ senf::scheduler::FdEvent::~FdEvent()
42 {
43     if (detail::FdDispatcher::alive())
44         disable();
45 }
46
47 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::action(Callback const & cb)
48 {
49     cb_ = cb;
50     return *this;
51 }
52
53 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::addEvents(int e)
54 {
55     events( events() | e );
56     return *this;
57 }
58
59 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::removeEvents(int e)
60 {
61     events( events() & ~e );
62     return *this;
63 }
64
65 prefix_ int senf::scheduler::FdEvent::events()
66 {
67     return events_;
68 }
69
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 // senf::scheduler::detail::FdDispatcher
72
73 prefix_ senf::scheduler::detail::FdDispatcher::FdDispatcher()
74 {}
75
76 prefix_ bool senf::scheduler::detail::FdDispatcher::empty()
77     const
78 {
79     return fds_.empty();
80 }
81
82 //-/////////////////////////////////////////////////////////////////////////////////////////////////
83 // senf::scheduler::detail::FileDispatcher
84
85 prefix_ void senf::scheduler::detail::FileDispatcher::timeout(int t)
86 {
87     managerTimeout_ = t;
88     if (fds_.empty())
89         detail::FdManager::instance().timeout(managerTimeout_);
90 }
91
92 prefix_ int senf::scheduler::detail::FileDispatcher::timeout()
93     const
94 {
95     return managerTimeout_;
96 }
97
98 prefix_ bool senf::scheduler::detail::FileDispatcher::empty()
99     const
100 {
101     return fds_.empty();
102 }
103
104 //-/////////////////////////////////////////////////////////////////////////////////////////////////
105
106 prefix_ int senf::scheduler::detail::retrieve_filehandle(int fd)
107 {
108     return fd;
109 }
110
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
112 #undef prefix_
113
114 \f
115 // Local Variables:
116 // mode: c++
117 // fill-column: 100
118 // comment-column: 40
119 // c-file-style: "senf"
120 // indent-tabs-mode: nil
121 // ispell-local-dictionary: "american"
122 // compile-command: "scons -u test"
123 // End: