Socket/Protocols/INet: Implement SSM Multicast API
[senf.git] / Scheduler / FIFORunner.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 FIFORunner inline non-template implementation */
25
26 //#include "FIFORunner.ih"
27
28 // Custom includes
29 #ifdef SENF_DEBUG
30 #include <sstream>
31 #include "../Utils/Backtrace.hh"
32 #endif
33
34 #define prefix_ inline
35 ///////////////////////////////cci.p///////////////////////////////////////
36
37 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string const & name)
38     : Event(name), runnable_ (false)
39 {}
40
41 prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::~TaskInfo()
42 {}
43
44 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::setRunnable()
45 {
46     runnable_ = true;
47 }
48
49 prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run()
50 {
51     countRun();
52     // Be sure to run v_run last since the callback may destroy this instance
53     v_run();
54 }
55
56 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::runnable()
57     const
58 {
59     return runnable_;
60 }
61
62 prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::v_enabled()
63     const
64 {
65     return TaskListBase::linked();
66 }
67
68 prefix_ void senf::scheduler::detail::FIFORunner::enqueue(TaskInfo * task)
69 {
70     tasks_.push_back(*task);
71 #ifdef SENF_DEBUG
72     std::stringstream ss;
73     backtrace(ss, 32);
74     task->backtrace_ = ss.str();
75 #endif
76 }
77
78 prefix_ void senf::scheduler::detail::FIFORunner::taskTimeout(unsigned ms)
79 {
80     watchdogMs_ = ms;
81 }
82
83 prefix_ unsigned senf::scheduler::detail::FIFORunner::taskTimeout()
84     const
85 {
86     return watchdogMs_;
87 }
88
89 prefix_ unsigned senf::scheduler::detail::FIFORunner::hangCount()
90     const
91 {
92     return hangCount_;
93 }
94
95 prefix_ senf::scheduler::detail::FIFORunner::iterator
96 senf::scheduler::detail::FIFORunner::begin()
97     const
98 {
99     // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added is such
100     // an element and must be skipped.
101     return boost::make_filter_iterator(
102         EventManager::IteratorFilter(), tasks_.begin(), tasks_.end());
103 }
104
105 prefix_ senf::scheduler::detail::FIFORunner::iterator senf::scheduler::detail::FIFORunner::end()
106     const
107 {
108     return boost::make_filter_iterator(
109         EventManager::IteratorFilter(), tasks_.end(), tasks_.end());
110 }
111
112 ///////////////////////////////cci.e///////////////////////////////////////
113 #undef prefix_
114
115 \f
116 // Local Variables:
117 // mode: c++
118 // fill-column: 100
119 // comment-column: 40
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // End: