4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Joins non-inline non-template implementation */
36 #include <boost/bind.hpp>
37 #include <boost/lambda/lambda.hpp>
38 #include <boost/lambda/bind.hpp>
40 //#include "Joins.mpp"
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 // senf::ppi::module::PassiveJoin
47 prefix_ senf::ppi::module::PassiveJoin::PassiveJoin()
50 output.onThrottle(&PassiveJoin::onThrottle);
51 output.onUnthrottle(&PassiveJoin::onUnthrottle);
54 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 prefix_ void senf::ppi::module::PassiveJoin::connectorSetup(connector::PassiveInput<> & conn)
60 conn.onRequest(boost::bind(&PassiveJoin::request,this,boost::ref(conn)));
61 conn.qdisc( QueueingDiscipline::NONE);
64 prefix_ void senf::ppi::module::PassiveJoin::onThrottle()
66 using boost::lambda::_1;
67 using boost::lambda::bind;
68 std::for_each(connectors().begin(), connectors().end(),
69 bind(&connector::GenericPassiveInput::throttle, _1));
72 prefix_ void senf::ppi::module::PassiveJoin::onUnthrottle()
74 using boost::lambda::_1;
75 using boost::lambda::bind;
76 std::for_each(connectors().begin(), connectors().end(),
77 bind(&connector::GenericPassiveInput::unthrottle, _1));
80 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 // senf::ppi::module::PriorityJoin
83 prefix_ senf::ppi::module::PriorityJoin::PriorityJoin()
86 output.onRequest(&PriorityJoin::request);
89 //-/////////////////////////////////////////////////////////////////////////////////////////////////
93 senf::ppi::module::PriorityJoin::connectorSetup(PriorityJoin::ConnectorType & conn,
97 conn.onThrottle(&PriorityJoin::onThrottle);
98 conn.onUnthrottle(&PriorityJoin::onUnthrottle);
101 priority = connectors().size() + priority;
105 if (priority >= int(connectors().size())-1)
108 connectors().insert(connectors().begin()+priority, connectors().pop_back().release());
111 prefix_ void senf::ppi::module::PriorityJoin::request()
113 using boost::lambda::_1;
114 using boost::lambda::bind;
115 PriorityJoin::ContainerType::iterator i (
116 std::find_if(connectors().begin(), connectors().end(),
117 ! bind(&connector::GenericActiveInput::throttled, _1)));
118 if (i != connectors().end())
122 prefix_ void senf::ppi::module::PriorityJoin::onThrottle()
124 if (std::find_if(connectors().begin(), connectors().end(),
125 ! bind(&connector::GenericActiveInput::throttled, _1)) == connectors().end())
129 prefix_ void senf::ppi::module::PriorityJoin::onUnthrottle()
134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
136 //#include "Joins.mpp"
142 // comment-column: 40
143 // c-file-style: "senf"
144 // indent-tabs-mode: nil
145 // ispell-local-dictionary: "american"
146 // compile-command: "scons -u test"