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 Joins non-inline non-template implementation */
31 #include <boost/bind.hpp>
32 #include <boost/lambda/lambda.hpp>
33 #include <boost/lambda/bind.hpp>
35 //#include "Joins.mpp"
37 ///////////////////////////////cc.p////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////
40 // senf::ppi::module::PassiveJoin
42 prefix_ senf::ppi::module::PassiveJoin::PassiveJoin()
45 output.onThrottle(&PassiveJoin::onThrottle);
46 output.onUnthrottle(&PassiveJoin::onUnthrottle);
49 ////////////////////////////////////////
52 prefix_ void senf::ppi::module::PassiveJoin::connectorSetup(connector::PassiveInput<> & conn)
55 conn.onRequest(boost::bind(&PassiveJoin::request,this,boost::ref(conn)));
56 conn.qdisc( QueueingDiscipline::NONE);
59 prefix_ void senf::ppi::module::PassiveJoin::onThrottle()
61 using boost::lambda::_1;
62 using boost::lambda::bind;
63 std::for_each(connectors().begin(), connectors().end(),
64 bind(&connector::GenericPassiveInput::throttle, _1));
67 prefix_ void senf::ppi::module::PassiveJoin::onUnthrottle()
69 using boost::lambda::_1;
70 using boost::lambda::bind;
71 std::for_each(connectors().begin(), connectors().end(),
72 bind(&connector::GenericPassiveInput::unthrottle, _1));
75 ///////////////////////////////////////////////////////////////////////////
76 // senf::ppi::module::PriorityJoin
78 prefix_ senf::ppi::module::PriorityJoin::PriorityJoin()
81 output.onRequest(&PriorityJoin::request);
84 ////////////////////////////////////////
88 senf::ppi::module::PriorityJoin::connectorSetup(PriorityJoin::ConnectorType & conn,
92 conn.onThrottle(&PriorityJoin::onThrottle);
93 conn.onUnthrottle(&PriorityJoin::onUnthrottle);
96 priority = connectors().size() + priority;
100 if (priority >= int(connectors().size())-1)
103 connectors().insert(connectors().begin()+priority, connectors().pop_back().release());
106 prefix_ void senf::ppi::module::PriorityJoin::request()
108 using boost::lambda::_1;
109 using boost::lambda::bind;
110 PriorityJoin::ContainerType::iterator i (
111 std::find_if(connectors().begin(), connectors().end(),
112 ! bind(&connector::GenericActiveInput::throttled, _1)));
113 if (i != connectors().end())
117 prefix_ void senf::ppi::module::PriorityJoin::onThrottle()
119 if (std::find_if(connectors().begin(), connectors().end(),
120 ! bind(&connector::GenericActiveInput::throttled, _1)) == connectors().end())
124 prefix_ void senf::ppi::module::PriorityJoin::onUnthrottle()
129 ///////////////////////////////cc.e////////////////////////////////////////
131 //#include "Joins.mpp"
137 // comment-column: 40
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"