commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8162 - in gnuradio/branches/developers/eb/gcell-wip/g


From: eb
Subject: [Commit-gnuradio] r8162 - in gnuradio/branches/developers/eb/gcell-wip/gcell/src: apps lib/runtime
Date: Tue, 8 Apr 2008 17:24:50 -0600 (MDT)

Author: eb
Date: 2008-04-08 17:24:49 -0600 (Tue, 08 Apr 2008)
New Revision: 8162

Modified:
   gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/benchmark_nop.cc
   
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.cc
   
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.h
   
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/qa_job_manager.cc
Log:
added gc_job_manager::singleton()

Modified: 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/benchmark_nop.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/benchmark_nop.cc   
2008-04-08 22:35:42 UTC (rev 8161)
+++ gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/benchmark_nop.cc   
2008-04-08 23:24:49 UTC (rev 8162)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 

Modified: 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.cc
===================================================================
--- 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.cc
   2008-04-08 22:35:42 UTC (rev 8161)
+++ 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.cc
   2008-04-08 23:24:49 UTC (rev 8162)
@@ -24,7 +24,12 @@
 #endif
 #include "gc_job_manager.h"
 #include "gc_job_manager_impl.h"
+#include <boost/weak_ptr.hpp>
 
+
+static boost::weak_ptr<gc_job_manager> s_singleton;
+
+
 gc_job_manager_sptr
 gc_make_job_manager(const gc_jm_options *options)
 {
@@ -53,6 +58,21 @@
   return 0;
 }
 
+void 
+gc_job_manager::set_singleton(gc_job_manager_sptr mgr)
+{
+  s_singleton = mgr;
+}
+
+gc_job_manager_sptr 
+gc_job_manager::singleton()
+{
+  return gc_job_manager_sptr(s_singleton);
+}
+
+// ------------------------------------------------------------------------
+
+
 // custom deleter
 class spe_program_handle_deleter {
 public:
@@ -86,3 +106,5 @@
 {
   return spe_program_handle_sptr(handle, nop_spe_program_handle_deleter());
 }
+
+

Modified: 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.h
===================================================================
--- 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.h
    2008-04-08 22:35:42 UTC (rev 8161)
+++ 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/gc_job_manager.h
    2008-04-08 23:24:49 UTC (rev 8162)
@@ -195,6 +195,27 @@
    */
   virtual std::vector<std::string> proc_names() = 0;
 
+  /*!
+   * \brief Set the singleton gc_job_manager instance.
+   * \param mgr is the job manager instance.
+   *
+   * The singleton is weakly held, thus the caller must maintain
+   * a reference to the mgr for the duration.  (If we held the
+   * manager strongly, the destructor would never be called, and the
+   * resources (SPEs) would not be returned.)  Bottom line: the
+   * caller is responsible for life-time management.
+   */
+  static void set_singleton(gc_job_manager_sptr mgr);
+
+  /*!
+   * \brief Retrieve the singleton gc_job_manager instance.
+   *
+   * Returns the singleton gc_job_manager instance or raises
+   * boost::bad_weak_ptr if the singleton is empty.
+   */
+  static gc_job_manager_sptr singleton();
+
+
   virtual void set_debug(int debug);
   virtual int debug();
 };

Modified: 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/qa_job_manager.cc
===================================================================
--- 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/qa_job_manager.cc
   2008-04-08 22:35:42 UTC (rev 8161)
+++ 
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/qa_job_manager.cc
   2008-04-08 23:24:49 UTC (rev 8162)
@@ -775,4 +775,14 @@
 void
 qa_job_manager::t15_body()
 {
+  gc_jm_options opts;
+  opts.program_handle = gc_program_handle_from_address(&gcell_qa);
+  opts.nspes = 1;
+  gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+  gc_job_manager::set_singleton(mgr);
+
+  CPPUNIT_ASSERT(gc_job_manager::singleton());
+  mgr.reset();
+  CPPUNIT_ASSERT_THROW(gc_job_manager::singleton(), boost::bad_weak_ptr);
 }





reply via email to

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