commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/06: Provided thread safety to dynamic re


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/06: Provided thread safety to dynamic repeat
Date: Sun, 27 Dec 2015 21:43:03 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 90ba3ea311f4c395366fdafe36b1a9d416c70cc5
Author: Marcus Müller <address@hidden>
Date:   Sun Aug 30 15:00:51 2015 +0200

    Provided thread safety to dynamic repeat
    
    ... by wrapping the actual setter in a message handler and writing a
    delegate _post()er.
---
 gr-blocks/include/gnuradio/blocks/repeat.h |  4 ++++
 gr-blocks/lib/repeat_impl.cc               | 17 +++++++++++++++--
 gr-blocks/lib/repeat_impl.h                |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/gr-blocks/include/gnuradio/blocks/repeat.h 
b/gr-blocks/include/gnuradio/blocks/repeat.h
index 1de2a74..b34bda1 100644
--- a/gr-blocks/include/gnuradio/blocks/repeat.h
+++ b/gr-blocks/include/gnuradio/blocks/repeat.h
@@ -32,6 +32,10 @@ namespace gr {
     /*!
      * \brief repeat each input \p repeat times
      * \ingroup stream_operators_blk
+     *
+     * Message Ports:
+     *   * interpolation (in):
+     *      Takes a pmt_pair(pmt::mp("interpolation"), pmt_long interp), 
setting the interpolation to interp.
      */
     class BLOCKS_API repeat : virtual public sync_interpolator
     {
diff --git a/gr-blocks/lib/repeat_impl.cc b/gr-blocks/lib/repeat_impl.cc
index b32efef..fb62265 100644
--- a/gr-blocks/lib/repeat_impl.cc
+++ b/gr-blocks/lib/repeat_impl.cc
@@ -43,13 +43,26 @@ namespace gr {
        d_itemsize(itemsize),
        d_interp(interp)
     {
+        message_port_register_in(pmt::mp("interpolation"));
+        set_msg_handler(pmt::mp("interpolation"),
+                boost::bind(&repeat_impl::msg_set_interpolation, this, _1));
     }
 
     void
+    repeat_impl::msg_set_interpolation(pmt::pmt_t msg)
+    {
+        // Dynamization by Kevin McQuiggin:
+        d_interp = pmt::to_long(pmt::cdr(msg));
+        sync_interpolator::set_interpolation(d_interp);
+    }
+    void
     repeat_impl::set_interpolation(int interp)
     {
-      d_interp = interp;
-      sync_interpolator::set_interpolation(d_interp);
+        // This ensures that interpolation is only changed between calls to 
work
+        // (and not in the middle of an ongoing work)
+        _post(  pmt::mp("interpolation"), /* port */
+                pmt::cons(pmt::mp("interpolation"), pmt::from_long(interp)) /* 
pair */
+        );
     }
 
     int
diff --git a/gr-blocks/lib/repeat_impl.h b/gr-blocks/lib/repeat_impl.h
index 2f4f411..486a47a 100644
--- a/gr-blocks/lib/repeat_impl.h
+++ b/gr-blocks/lib/repeat_impl.h
@@ -43,6 +43,8 @@ namespace gr {
       int work(int noutput_items,
               gr_vector_const_void_star &input_items,
               gr_vector_void_star &output_items);
+    private:
+      void msg_set_interpolation(pmt::pmt_t msg);
     };
 
   } /* namespace blocks */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]