[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8886 - in gnuradio/branches/developers/eb/sched-wip:
From: |
eb |
Subject: |
[Commit-gnuradio] r8886 - in gnuradio/branches/developers/eb/sched-wip: gnuradio-core/src/lib gruel/src/include/gruel gruel/src/lib |
Date: |
Mon, 14 Jul 2008 20:18:08 -0600 (MDT) |
Author: eb
Date: 2008-07-14 20:18:07 -0600 (Mon, 14 Jul 2008)
New Revision: 8886
Added:
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/thread_group.h
gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/thread_group.cc
Modified:
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/Makefile.am
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/Makefile.am
gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/Makefile.am
Log:
added fixed thread_group to gruel
Modified:
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/Makefile.am
2008-07-15 01:03:05 UTC (rev 8885)
+++ gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/Makefile.am
2008-07-15 02:18:07 UTC (rev 8886)
@@ -31,8 +31,7 @@
lib_LTLIBRARIES = libgnuradio-core.la libgnuradio-core-qa.la
libgnuradio_core_la_SOURCES = bug_work_around_6.cc
-libgnuradio_core_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 \
- $(BOOST_LDFLAGS)
+libgnuradio_core_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
libgnuradio_core_qa_la_SOURCES = bug_work_around_6.cc
libgnuradio_core_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 \
@@ -51,8 +50,7 @@
runtime/libruntime.la \
$(OMNITHREAD_LA) \
$(GRUEL_LA) \
- $(FFTW3F_LIBS) \
- $(BOOST_THREAD_LIB)
+ $(FFTW3F_LIBS)
libgnuradio_core_qa_la_LIBADD = \
filter/libfilter-qa.la \
Modified:
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/Makefile.am
===================================================================
---
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/Makefile.am
2008-07-15 01:03:05 UTC (rev 8885)
+++
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/Makefile.am
2008-07-15 02:18:07 UTC (rev 8886)
@@ -28,4 +28,5 @@
gruelinclude_HEADERS = \
$(BUILT_SOURCES) \
- realtime.h
+ realtime.h \
+ thread_group.h
Added:
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/thread_group.h
===================================================================
---
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/thread_group.h
(rev 0)
+++
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/thread_group.h
2008-07-15 02:18:07 UTC (rev 8886)
@@ -0,0 +1,39 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2001-2003 William E. Kempf
+ * Copyright (C) 2007 Anthony Williams
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+/*
+ * This was extracted from Boost 1.35.0 and fixed.
+ */
+
+#include <boost/utility.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/function.hpp>
+
+namespace gruel
+{
+ class thread_group : public boost::noncopyable
+ {
+ public:
+ thread_group();
+ ~thread_group();
+
+ boost::thread* create_thread(const boost::function0<void>& threadfunc);
+ void add_thread(boost::thread* thrd);
+ void remove_thread(boost::thread* thrd);
+ void join_all();
+ void interrupt_all();
+ size_t size() const;
+
+ private:
+ std::list<boost::thread*> m_threads;
+ mutable boost::shared_mutex m_mutex;
+ };
+}
Property changes on:
gnuradio/branches/developers/eb/sched-wip/gruel/src/include/gruel/thread_group.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/Makefile.am
2008-07-15 01:03:05 UTC (rev 8885)
+++ gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/Makefile.am
2008-07-15 02:18:07 UTC (rev 8886)
@@ -25,16 +25,17 @@
lib_LTLIBRARIES = libgruel.la
+# magic flags
+libgruel_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) -version-info 0:0:0
+
# These are the source files that go into the gruel shared library
libgruel_la_SOURCES = \
realtime.cc \
- thread_body_wrapper.cc
+ thread_body_wrapper.cc \
+ thread_group.cc
-# magic flags
-libgruel_la_LDFLAGS = $(NO_UNDEFINED)
-
-# link the library against the c++ standard library
libgruel_la_LIBADD = \
+ $(BOOST_THREAD_LIB)
-lstdc++
noinst_HEADERS =
Added: gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/thread_group.cc
===================================================================
--- gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/thread_group.cc
(rev 0)
+++ gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/thread_group.cc
2008-07-15 02:18:07 UTC (rev 8886)
@@ -0,0 +1,99 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2001-2003 William E. Kempf
+ * Copyright (C) 2007 Anthony Williams
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+/*
+ * This was extracted from Boost 1.35.0 and fixed.
+ */
+
+#include <gruel/thread_group.h>
+
+namespace gruel
+{
+ thread_group::thread_group()
+ {
+ }
+
+ thread_group::~thread_group()
+ {
+ // We shouldn't have to scoped_lock here, since referencing this object
+ // from another thread while we're deleting it in the current thread is
+ // going to lead to undefined behavior any way.
+ for (std::list<boost::thread*>::iterator it = m_threads.begin();
+ it != m_threads.end(); ++it)
+ {
+ delete (*it);
+ }
+ }
+
+ boost::thread* thread_group::create_thread(const boost::function0<void>&
threadfunc)
+ {
+ // No scoped_lock required here since the only "shared data" that's
+ // modified here occurs inside add_thread which does scoped_lock.
+ std::auto_ptr<boost::thread> thrd(new boost::thread(threadfunc));
+ add_thread(thrd.get());
+ return thrd.release();
+ }
+
+ void thread_group::add_thread(boost::thread* thrd)
+ {
+ boost::lock_guard<boost::shared_mutex> guard(m_mutex);
+
+ // For now we'll simply ignore requests to add a thread object multiple
+ // times. Should we consider this an error and either throw or return an
+ // error value?
+ std::list<boost::thread*>::iterator it = std::find(m_threads.begin(),
+ m_threads.end(), thrd);
+ BOOST_ASSERT(it == m_threads.end());
+ if (it == m_threads.end())
+ m_threads.push_back(thrd);
+ }
+
+ void thread_group::remove_thread(boost::thread* thrd)
+ {
+ boost::lock_guard<boost::shared_mutex> guard(m_mutex);
+
+ // For now we'll simply ignore requests to remove a thread object that's
+ // not in the group. Should we consider this an error and either throw or
+ // return an error value?
+ std::list<boost::thread*>::iterator it = std::find(m_threads.begin(),
+ m_threads.end(), thrd);
+ BOOST_ASSERT(it != m_threads.end());
+ if (it != m_threads.end())
+ m_threads.erase(it);
+ }
+
+ void thread_group::join_all()
+ {
+ boost::shared_lock<boost::shared_mutex> guard(m_mutex);
+ for (std::list<boost::thread*>::iterator it = m_threads.begin();
+ it != m_threads.end(); ++it)
+ {
+ (*it)->join();
+ }
+ }
+
+ void thread_group::interrupt_all()
+ {
+ boost::shared_lock<boost::shared_mutex> guard(m_mutex);
+ for(std::list<boost::thread*>::iterator
it=m_threads.begin(),end=m_threads.end();
+ it!=end;
+ ++it)
+ {
+ (*it)->interrupt();
+ }
+ }
+
+ size_t thread_group::size() const
+ {
+ boost::shared_lock<boost::shared_mutex> guard(m_mutex);
+ return m_threads.size();
+ }
+
+} // namespace gruel
Property changes on:
gnuradio/branches/developers/eb/sched-wip/gruel/src/lib/thread_group.cc
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8886 - in gnuradio/branches/developers/eb/sched-wip: gnuradio-core/src/lib gruel/src/include/gruel gruel/src/lib,
eb <=