commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4977 - gnuradio/branches/developers/eb/ibu/mblock/src


From: eb
Subject: [Commit-gnuradio] r4977 - gnuradio/branches/developers/eb/ibu/mblock/src/lib
Date: Thu, 12 Apr 2007 22:53:48 -0600 (MDT)

Author: eb
Date: 2007-04-12 22:53:48 -0600 (Thu, 12 Apr 2007)
New Revision: 4977

Modified:
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/benchmark_send.cc
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock.cc
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.cc
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.h
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port.h
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.cc
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.h
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime.h
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_nop.h
   
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_block.cc
Log:
work-in-progress on mblocks

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/benchmark_send.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/benchmark_send.cc        
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/benchmark_send.cc        
2007-04-13 04:53:48 UTC (rev 4977)
@@ -29,7 +29,7 @@
   pmt_t result = PMT_NIL;
 
   long nmsgs =      1000000;
-  long batch_size =       8;
+  long batch_size =     100;
 
   pmt_t arg = pmt_list2(pmt_from_long(nmsgs),  // # of messages to send 
through pipe
                        pmt_from_long(batch_size));

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock.cc     
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock.cc     
2007-04-13 04:53:48 UTC (rev 4977)
@@ -48,9 +48,6 @@
 
 mb_mblock::~mb_mblock()
 {
-  disconnect_all();
-
-  // FIXME more?
 }
 
 

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.cc        
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.cc        
2007-04-13 04:53:48 UTC (rev 4977)
@@ -30,8 +30,8 @@
 #include <mb_exception.h>
 #include <mb_util.h>
 #include <mb_msg_accepter_smp.h>
-//#include <mb_runtime_placeholder.h>
 #include <mbi_runtime_lock.h>
+#include <iostream>
 
 
 static pmt_t s_self = pmt_intern("self");
@@ -139,6 +139,7 @@
   mbi_runtime_lock     l(this);
 
   d_conn_table.disconnect(comp_name1, port_name1, comp_name2, port_name2);
+  invalidate_all_port_caches();
 }
 
 void
@@ -147,6 +148,7 @@
   mbi_runtime_lock     l(this);
 
   d_conn_table.disconnect_component(component_name);
+  invalidate_all_port_caches();
 }
 
 void
@@ -155,6 +157,7 @@
   mbi_runtime_lock     l(this);
 
   d_conn_table.disconnect_all();
+  invalidate_all_port_caches();
 }
 
 int
@@ -293,3 +296,42 @@
 {
   d_class_name = name;
 }
+
+/*
+ * This is the "Big Hammer" port cache invalidator.
+ * It invalidates _all_ of the port caches in the entire mblock tree.
+ * It's overkill, but was simple to code.
+ */
+void
+mb_mblock_impl::invalidate_all_port_caches()
+{
+  class invalidator : public mb_visitor
+  {
+  public:
+    bool operator()(mb_mblock *mblock)
+    {
+      mb_mblock_impl_sptr impl = mblock->impl();
+      mb_port_map_t::iterator it = impl->d_port_map.begin();
+      mb_port_map_t::iterator end = impl->d_port_map.end();
+      for (; it != end; ++it)
+       it->second->invalidate_cache();
+      return true;
+    }
+  };
+
+  class nop : public mb_visitor
+  {
+  public:
+    bool operator()(mb_mblock *mblock)
+    {
+      return true;
+    }
+  };
+
+  invalidator visitor;
+  nop visitor2;
+
+  // Always true, except in early QA code
+  if (runtime()->top())
+    runtime()->top()->walk_tree(&visitor2);
+}

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.h 
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_mblock_impl.h 
2007-04-13 04:53:48 UTC (rev 4977)
@@ -212,6 +212,12 @@
   endpoints_are_compatible(const mb_endpoint &ep0,
                           const mb_endpoint &ep1);
 
+  /*!
+   * \brief walk mblock tree and invalidate all port resolution caches.
+   * \implementation
+   */
+  void
+  invalidate_all_port_caches();
 };
 
 

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port.h        
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port.h        
2007-04-13 04:53:48 UTC (rev 4977)
@@ -82,6 +82,12 @@
        pmt_t data = PMT_NIL,
        pmt_t metadata = PMT_NIL,
        mb_pri_t priority = MB_PRI_DEFAULT) = 0;
+
+  /*
+   * \brief Invalidate any cached peer resolutions
+   * \implementation
+   */
+  virtual void invalidate_cache() = 0;
 };
 
 #endif /* INCLUDED_MB_PORT_H */

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.cc        
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.cc        
2007-04-13 04:53:48 UTC (rev 4977)
@@ -37,7 +37,8 @@
                               const std::string &protocol_class_name,
                               bool conjugated,
                               mb_port::port_type_t port_type)
-  : mb_port(mblock, port_name, protocol_class_name, conjugated, port_type)
+  : mb_port(mblock, port_name, protocol_class_name, conjugated, port_type),
+    d_cache_valid(false)
 {
 }
 
@@ -67,6 +68,9 @@
   mb_endpoint          peer_ep;
   mb_msg_accepter_sptr r;
 
+  if (start->d_cache_valid)
+    return start->d_cached_accepter;
+
   mbi_runtime_lock     l(p->mblock());
 
   // Set up initial context.
@@ -99,7 +103,11 @@
   case mb_port::INTERNAL:      // Terminate here.
   case mb_port::EXTERNAL:
     r = pp->make_accepter();
-    // FIXME cache the result
+
+    // cache the result
+
+    start->d_cached_accepter = r;
+    start->d_cache_valid = true;
     return r;
 
   case mb_port::RELAY:         // Traverse to other side of relay port.
@@ -134,3 +142,10 @@
 {
   return d_mblock->impl()->make_accepter(port_symbol());
 }
+
+void
+mb_port_simple::invalidate_cache()
+{
+  d_cache_valid = false;
+  d_cached_accepter.reset();
+}

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.h 
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_port_simple.h 
2007-04-13 04:53:48 UTC (rev 4977)
@@ -28,6 +28,9 @@
  */
 class mb_port_simple : public mb_port
 {
+  bool                 d_cache_valid;
+  mb_msg_accepter_sptr d_cached_accepter;
+
 protected:
   static mb_msg_accepter_sptr
   find_accepter(mb_port_simple *start);
@@ -57,6 +60,13 @@
        pmt_t data = PMT_NIL,
        pmt_t metadata = PMT_NIL,
        mb_pri_t priority = MB_PRI_DEFAULT);
+
+  /*
+   * \brief Invalidate any cached peer resolutions
+   * \implementation
+   */
+  void invalidate_cache();
+
 };
 
 #endif /* INCLUDED_MB_PORT_SIMPLE_H */

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime.h     
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime.h     
2007-04-13 04:53:48 UTC (rev 4977)
@@ -39,8 +39,12 @@
 {
   friend class mb_mblock_impl;
 
-  omni_mutex   d_brl;          // big runtime lock (avoid using this if 
possible...)
+  omni_mutex           d_brl;  // big runtime lock (avoid using this if 
possible...)
 
+protected:  
+  mb_mblock_sptr       d_top;
+  
+
 public:
   mb_runtime(){}
   virtual ~mb_runtime();
@@ -81,6 +85,8 @@
 
   virtual void request_shutdown(pmt_t result);
 
+  mb_mblock_sptr top() { return d_top; }
+
 protected:
   virtual mb_mblock_sptr
   create_component(const std::string &instance_name,

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_nop.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_nop.h 
2007-04-13 04:05:26 UTC (rev 4976)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_nop.h 
2007-04-13 04:53:48 UTC (rev 4977)
@@ -33,8 +33,6 @@
  */
 class mb_runtime_nop : public mb_runtime
 {
-  mb_mblock_sptr       d_top;
-  
 public:
   mb_runtime_nop();
   ~mb_runtime_nop();
@@ -44,9 +42,6 @@
           pmt_t user_arg,
           pmt_t *result);
 
-  // QA only
-  mb_mblock_sptr top() { return d_top; }
-
 protected:
   mb_mblock_sptr
   create_component(const std::string &instance_name,

Modified: 
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_block.cc
===================================================================
--- 
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_block.cc
   2007-04-13 04:05:26 UTC (rev 4976)
+++ 
gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_runtime_thread_per_block.cc
   2007-04-13 04:53:48 UTC (rev 4977)
@@ -94,13 +94,20 @@
    * Create the top-level component, and recursively all of its
    * subcomponents.
    */
-  mb_mblock_sptr top = create_component(instance_name, class_name, user_arg);
+  d_top = create_component(instance_name, class_name, user_arg);
 
-  run_loop();
+  try {
+    run_loop();
+  }
+  catch (...){
+    d_top.reset();
+    throw;
+  }
 
   if (result)
     *result = d_shutdown_result;
   
+  d_top.reset();
   return true;
 }
 





reply via email to

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