diff --git a/grc/foo_periodic_msg_source.xml b/grc/foo_periodic_msg_source.xml
index a27ffbc..48b07ed 100644
--- a/grc/foo_periodic_msg_source.xml
+++ b/grc/foo_periodic_msg_source.xml
@@ -40,9 +40,15 @@
int
+
+ eof in
+ message
+ 1
+
+
out
message
- 1
+ 1
diff --git a/lib/periodic_msg_source_impl.cc b/lib/periodic_msg_source_impl.cc
index fad0288..07b1786 100644
--- a/lib/periodic_msg_source_impl.cc
+++ b/lib/periodic_msg_source_impl.cc
@@ -33,9 +33,13 @@ periodic_msg_source_impl::periodic_msg_source_impl(pmt::pmt_t msg,
d_num_msg(num_msg),
d_interval(interval),
d_debug(debug),
- d_finished(false) {
+ d_finished(false) {
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(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();
}
+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
periodic_msg_source_impl::run(periodic_msg_source_impl *instance) {
-
// flow graph startup delay
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
diff --git a/lib/periodic_msg_source_impl.h b/lib/periodic_msg_source_impl.h
index 8b31259..7f3a97c 100644
--- a/lib/periodic_msg_source_impl.h
+++ b/lib/periodic_msg_source_impl.h
@@ -25,6 +25,7 @@ namespace foo {
class periodic_msg_source_impl : public periodic_msg_source {
private:
void run(periodic_msg_source_impl *instance);
+ void eof_in(pmt::pmt_t msg);
int d_num_msg;
bool d_debug;