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