periodic msg source: add eof input

to stop non-GUI flow graphs
This commit is contained in:
Bastian Bloessl
2014-08-22 10:31:44 +02:00
parent 66719c9453
commit b3fbecfc68
3 changed files with 22 additions and 3 deletions
+6
View File
@@ -40,6 +40,12 @@
<type>int</type> <type>int</type>
</param> </param>
<sink>
<name>eof in</name>
<type>message</type>
<optional>1</optional>
</sink>
<source> <source>
<name>out</name> <name>out</name>
<type>message</type> <type>message</type>
+13 -1
View File
@@ -36,6 +36,10 @@ periodic_msg_source_impl::periodic_msg_source_impl(pmt::pmt_t msg,
d_finished(false) { d_finished(false) {
message_port_register_out(pmt::mp("out")); message_port_register_out(pmt::mp("out"));
message_port_register_in(pmt::mp("eof in"));
set_msg_handler(pmt::mp("eof in"), boost::bind(&periodic_msg_source_impl::eof_in, this, _1));
d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&periodic_msg_source_impl::run, this, this))); d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&periodic_msg_source_impl::run, this, this)));
} }
@@ -45,10 +49,18 @@ periodic_msg_source_impl::~periodic_msg_source_impl() {
d_thread->join(); d_thread->join();
} }
void
periodic_msg_source_impl::eof_in (pmt::pmt_t msg) {
if(pmt::is_eof_object(msg)) {
detail().get()->set_done(true);
return;
} else {
dout << "non EOF message at eof port!" << std::endl;
}
}
void void
periodic_msg_source_impl::run(periodic_msg_source_impl *instance) { periodic_msg_source_impl::run(periodic_msg_source_impl *instance) {
// flow graph startup delay // flow graph startup delay
boost::this_thread::sleep(boost::posix_time::milliseconds(500)); boost::this_thread::sleep(boost::posix_time::milliseconds(500));
+1
View File
@@ -25,6 +25,7 @@ namespace foo {
class periodic_msg_source_impl : public periodic_msg_source { class periodic_msg_source_impl : public periodic_msg_source {
private: private:
void run(periodic_msg_source_impl *instance); void run(periodic_msg_source_impl *instance);
void eof_in(pmt::pmt_t msg);
int d_num_msg; int d_num_msg;
bool d_debug; bool d_debug;