commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11180 - gnuradio/branches/developers/eb/varying/gnura


From: eb
Subject: [Commit-gnuradio] r11180 - gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime
Date: Mon, 8 Jun 2009 15:30:01 -0600 (MDT)

Author: eb
Date: 2009-06-08 15:30:00 -0600 (Mon, 08 Jun 2009)
New Revision: 11180

Modified:
   
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.cc
   
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.h
   
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.cc
   
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.h
   
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_executor.cc
Log:
work-in-progress

Modified: 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.cc
===================================================================
--- 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.cc
   2009-06-08 18:52:14 UTC (rev 11179)
+++ 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.cc
   2009-06-08 21:30:00 UTC (rev 11180)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -99,6 +99,12 @@
   d_detail->consume_each (how_many_items);
 }
 
+void
+gr_block::produce (int which_output, int how_many_items)
+{
+  d_detail->produce (which_output, how_many_items);
+}
+
 int
 gr_block::fixed_rate_ninput_to_noutput(int ninput)
 {

Modified: 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.h
===================================================================
--- 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.h
    2009-06-08 18:52:14 UTC (rev 11179)
+++ 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block.h
    2009-06-08 21:30:00 UTC (rev 11180)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004,2007 Free Software Foundation, Inc.
+ * Copyright 2004,2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -57,6 +57,12 @@
 
  public:
   
+  //! Magic return values from general_work
+  enum {
+    WORK_CALLED_PRODUCE = -2,
+    WORK_DONE = -1
+  };
+
   virtual ~gr_block ();
 
   /*!
@@ -70,7 +76,7 @@
   void  set_history (unsigned history) { d_history = history; }
   
   /*!
-   * \brief return true if this block has a fixed input to output rate
+   * \brief Return true if this block has a fixed input to output rate.
    *
    * If true, then fixed_rate_in_to_out and fixed_rate_out_to_in may be called.
    */
@@ -150,6 +156,13 @@
   void consume_each (int how_many_items);
 
   /*!
+   * \brief Tell the scheduler \p how_many_items were produced on output 
stream \p which_output.
+   *
+   * If the block's general_work method calls produce, \p general_work must 
return WORK_CALLED_PRODUCE.
+   */
+  void produce (int which_output, int how_many_items);
+
+  /*!
    * \brief Set the approximate output rate / input rate
    *
    * Provide a hint to the buffer allocator and scheduler.
@@ -191,7 +204,7 @@
 
   int                   d_output_multiple;
   double                d_relative_rate;       // approx output_rate / 
input_rate
-  gr_block_detail_sptr d_detail;                   // implementation details
+  gr_block_detail_sptr d_detail;               // implementation details
   unsigned              d_history;
   bool                  d_fixed_rate;
     

Modified: 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.cc
===================================================================
--- 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.cc
    2009-06-08 18:52:14 UTC (rev 11179)
+++ 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.cc
    2009-06-08 21:30:00 UTC (rev 11180)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -36,7 +36,8 @@
 }
 
 gr_block_detail::gr_block_detail (unsigned int ninputs, unsigned int noutputs)
-  : d_ninputs (ninputs), d_noutputs (noutputs),
+  : d_produce_or(0),
+    d_ninputs (ninputs), d_noutputs (noutputs),
     d_input (ninputs), d_output (noutputs),
     d_done (false)
 {
@@ -100,9 +101,20 @@
 }
 
 void
+gr_block_detail::produce (int which_output, int how_many_items)
+{
+  if (how_many_items > 0){
+    d_output[which_output]->update_write_pointer (how_many_items);
+    d_produce_or |= how_many_items;
+  }
+}
+
+void
 gr_block_detail::produce_each (int how_many_items)
 {
-  if (how_many_items > 0)
+  if (how_many_items > 0){
     for (int i = 0; i < noutputs (); i++)
       d_output[i]->update_write_pointer (how_many_items);
+    d_produce_or |= how_many_items;
+  }
 }

Modified: 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.h
===================================================================
--- 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.h
     2009-06-08 18:52:14 UTC (rev 11179)
+++ 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_detail.h
     2009-06-08 21:30:00 UTC (rev 11180)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2009 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -74,12 +74,19 @@
   void consume_each (int how_many_items);
 
   /*!
+   * \brief Tell the scheduler \p how_many_items were produced on output 
stream \p which_output.
+   */
+  void produce (int which_output, int how_many_items);
+
+  /*!
    * \brief Tell the scheduler \p how_many_items were produced on each output 
stream.
    */
   void produce_each (int how_many_items);
 
 
+
   gr_tpb_detail                             d_tpb;     // used by 
thread-per-block scheduler
+  int                               d_produce_or;
 
   // 
----------------------------------------------------------------------------
 

Modified: 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_executor.cc
===================================================================
--- 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_executor.cc
  2009-06-08 18:52:14 UTC (rev 11179)
+++ 
gnuradio/branches/developers/eb/varying/gnuradio-core/src/lib/runtime/gr_block_executor.cc
  2009-06-08 21:30:00 UTC (rev 11180)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -290,6 +290,7 @@
 
   setup_call_to_work:
 
+    d->d_produce_or = 0;
     for (int i = 0; i < d->noutputs (); i++)
       d_output_items[i] = d->output(i)->write_pointer();
 
@@ -299,11 +300,13 @@
     LOG(*d_log << "  general_work: noutput_items = " << noutput_items
        << " result = " << n << std::endl);
 
-    if (n == -1)               // block is done
+    if (n == gr_block::WORK_DONE)
       goto were_done;
 
-    d->produce_each (n);       // advance write pointers
-    if (n > 0)
+    if (n != gr_block::WORK_CALLED_PRODUCE)
+      d->produce_each (n);     // advance write pointers
+    
+    if (d->d_produce_or > 0)   // block produced something
       return READY;
 
     // We didn't produce any output even though we called general_work.
@@ -312,7 +315,7 @@
     // If this is a source, it's broken.
     if (d->source_p()){
       std::cerr << "gr_block_executor: source " << m
-               << " returned 0 from work.  We're marking it DONE.\n";
+               << " produced no output.  We're marking it DONE.\n";
       // FIXME maybe we ought to raise an exception...
       goto were_done;
     }





reply via email to

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