[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4039 - gnuradio/branches/developers/jcorgan/hier/gnur
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r4039 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime |
Date: |
Tue, 28 Nov 2006 12:38:03 -0700 (MST) |
Author: jcorgan
Date: 2006-11-28 12:38:03 -0700 (Tue, 28 Nov 2006)
New Revision: 4039
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
Log:
The 'I hear hierarchical dialtone' check-in.
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
2006-11-28 19:10:33 UTC (rev 4038)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
2006-11-28 19:38:03 UTC (rev 4039)
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
* Copyright 2006 Free Software Foundation, Inc.
- *
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -40,12 +40,12 @@
d_graphs()
{
}
-
+
gr_runtime_impl::~gr_runtime_impl()
{
}
-void
+void
gr_runtime_impl::start()
{
if (GR_RUNTIME_IMPL_DEBUG)
@@ -63,11 +63,19 @@
d_graphs = d_sfg->d_detail->partition();
if (GR_RUNTIME_IMPL_DEBUG)
- std::cout << "Flow graph has " << d_graphs.size()
+ std::cout << "Flow graph has " << d_graphs.size()
<< " sub-graphs." << std::endl;
+
+ d_threads.clear();
+ for (std::vector<gr_block_vector_t>::iterator p = d_graphs.begin();
+ p != d_graphs.end(); p++) {
+ gr_scheduler_thread_sptr thread = gr_make_scheduler_thread(*p);
+ thread->start();
+ d_threads.push_back(thread);
+ }
}
-void
+void
gr_runtime_impl::stop()
{
if (GR_RUNTIME_IMPL_DEBUG)
@@ -75,14 +83,62 @@
if (!d_running)
return;
- // Stop
-
- d_running = false;
+ for (gr_scheduler_thread_viter_t p = d_threads.begin();
+ p != d_threads.end(); p++)
+ (*p)->stop();
+
+ d_running = false;
}
-void
+void
gr_runtime_impl::wait()
{
if (GR_RUNTIME_IMPL_DEBUG)
std::cout << "gr_runtime_impl::wait()" << std::endl;
+
+ for (gr_scheduler_thread_viter_t p = d_threads.begin();
+ p != d_threads.end(); p++) {
+ while(1) {
+ if (GR_RUNTIME_IMPL_DEBUG)
+ std::cout << "Thread state is " << (*p)->state() << std::endl;
+
+ (*p)->join(NULL);
+ if (!(*p)->state() == omni_thread::STATE_TERMINATED)
+ break;
+ }
+ }
}
+
+gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t graph)
+{
+ return gr_scheduler_thread_sptr(new gr_scheduler_thread(graph));
+}
+
+gr_scheduler_thread::gr_scheduler_thread(gr_block_vector_t graph) :
+ omni_thread(NULL, PRIORITY_NORMAL),
+ d_sts(gr_make_single_threaded_scheduler(graph))
+{
+}
+
+gr_scheduler_thread::~gr_scheduler_thread()
+{
+}
+
+void gr_scheduler_thread::start()
+{
+ start_undetached();
+}
+
+void *gr_scheduler_thread::run_undetached(void *arg)
+{
+ if (GR_RUNTIME_IMPL_DEBUG)
+ std::cout << "Running thread..." << std::endl;
+
+ d_sts->run();
+ return 0;
+}
+
+void gr_scheduler_thread::stop()
+{
+ d_sts->stop();
+}
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
2006-11-28 19:10:33 UTC (rev 4038)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.h
2006-11-28 19:38:03 UTC (rev 4039)
@@ -25,7 +25,31 @@
#include <gr_runtime_types.h>
#include <gr_block.h>
+#include <omnithread.h>
+#include <gr_single_threaded_scheduler.h>
+class gr_scheduler_thread;
+typedef boost::shared_ptr<gr_scheduler_thread> gr_scheduler_thread_sptr;
+typedef std::vector<gr_scheduler_thread_sptr> gr_scheduler_thread_vector_t;
+typedef std::vector<gr_scheduler_thread_sptr>::iterator
gr_scheduler_thread_viter_t;
+
+gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t graph);
+
+class gr_scheduler_thread : public omni_thread
+{
+private:
+ gr_scheduler_thread(gr_block_vector_t graph);
+ friend gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t
graph);
+
+ gr_single_threaded_scheduler_sptr d_sts;
+
+public:
+ ~gr_scheduler_thread();
+ virtual void *run_undetached(void *arg);
+ void start();
+ void stop();
+};
+
class gr_runtime_impl
{
private:
@@ -36,7 +60,8 @@
gr_hier_block2_sptr d_top_block;
gr_simple_flowgraph_sptr d_sfg;
std::vector<gr_block_vector_t> d_graphs;
-
+ gr_scheduler_thread_vector_t d_threads;
+
void start();
void stop();
void wait();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4039 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime,
jcorgan <=