////////////////////////////////////////
// private members
-prefix_ senf::ppi::connector::ActiveInput<> & senf::ppi::module::PriorityJoin::newInput()
+prefix_ senf::ppi::connector::ActiveInput<> &
+senf::ppi::module::PriorityJoin::newInput(int priority)
{
- inputs_.push_back(new connector::ActiveInput<>());
- connector::ActiveInput<> & input (inputs_.back());
+ if (priority > int(inputs_.size()))
+ priority = inputs_.size();
+ else if (priority < 0) {
+ priority = inputs_.size() + priority + 1;
+ if (priority < 0)
+ priority = 0;
+ }
+
+ connector::ActiveInput<> & input (
+ *inputs_.insert(inputs_.begin()+priority, new connector::ActiveInput<>()));
noroute(input);
input.onThrottle(&PriorityJoin::onThrottle);
template <class Source>
prefix_ senf::ppi::connector::GenericActiveInput &
-senf::ppi::module::PriorityJoin::connect(Source & source)
+senf::ppi::module::PriorityJoin::connect(Source & source, int priority)
{
- connector::GenericActiveInput & input (newInput());
+ connector::GenericActiveInput & input (newInput(priority));
ppi::connect(source,input);
return input;
}
#ifndef DOXYGEN
template <class Source>
-prefix_ senf::ppi::connector::GenericPassiveInput & senf::ppi::connect(Source & source,
- module::PassiveJoin & target)
+prefix_ senf::ppi::connector::GenericPassiveInput &
+senf::ppi::connect(Source & source, module::PassiveJoin & target)
{
return target.connect(source);
}
template <class Source>
-prefix_ senf::ppi::connector::GenericActiveInput & senf::ppi::connect(Source & source,
- module::PriorityJoin & target)
+prefix_ senf::ppi::connector::GenericActiveInput &
+senf::ppi::connect(Source & source, module::PriorityJoin & target, int priority)
{
- return target.connect(source);
+ return target.connect(source, priority);
}
#endif
connector::GenericPassiveInput & connect(Source & source, module::PassiveJoin & target);
template <class Source>
- connector::GenericActiveInput & connect(Source & source, module::PriorityJoin & target);
+ connector::GenericActiveInput & connect(Source & source, module::PriorityJoin & target,
+ int priority = -1);
#endif
PriorityJoin();
private:
- connector::ActiveInput<> & newInput();
+ connector::ActiveInput<> & newInput(int priority);
#ifndef DOXYGEN
public:
#endif
template <class Source>
- connector::GenericActiveInput & connect(Source & source);
+ connector::GenericActiveInput & connect(Source & source, int prioricty);
private:
void request();
BOOST_CHECK( sink.request() == p1 );
BOOST_CHECK( sink.request() == p2 );
BOOST_CHECK( ! sink );
+
+ debug::PassiveSource source3;
+ debug::PassiveSource source4;
+ ppi::connect(source3, join, 0);
+ ppi::connect(source4, join, -2);
+ // Ordering now: source3, source1, source4, source2
+
+ senf::Packet p3 (senf::DataPacket::create());
+ senf::Packet p4 (senf::DataPacket::create());
+
+ source4.submit(p4);
+ source3.submit(p3);
+ source2.submit(p2);
+ source1.submit(p1);
+ BOOST_CHECK( sink.request() == p3 );
+ BOOST_CHECK( sink.request() == p1 );
+ BOOST_CHECK( sink.request() == p4 );
+ BOOST_CHECK( sink.request() == p2 );
+ BOOST_CHECK( ! sink );
}
///////////////////////////////cc.e////////////////////////////////////////