Removed pmt dependency on omnithreads, now dependent on boost::threads
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 15 Jul 2009 02:39:28 +0000 (02:39 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 15 Jul 2009 02:39:28 +0000 (02:39 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11444 221aa14e-8319-0410-a670-987f0aec2ac5

config/grc_pmt.m4
pmt/pmt.pc.in
pmt/src/lib/Makefile.am
pmt/src/lib/pmt_pool.cc
pmt/src/lib/pmt_pool.h

index 8e0a58bcad2477c875d76672fae89501aac5a1fe..680acc9e4254f1861af737db3df4d54b02daf28e 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc.
+dnl Copyright 2001,2002,2003,2004,2005,2006,2008,2009 Free Software Foundation, Inc.
 dnl 
 dnl This file is part of GNU Radio
 dnl 
@@ -21,9 +21,6 @@ AC_DEFUN([GRC_PMT],[
     GRC_ENABLE(pmt)
     GRC_WITH(pmt)
 
-    dnl Don't do pmt if omnithread skipped
-    GRC_CHECK_DEPENDENCY(pmt, omnithread)
-
     dnl If execution gets to here, $passed will be:
     dnl   with : if the --with code didn't error out
     dnl   yes  : if the --enable code passed muster and all dependencies are met
index d6628cad60a21ebc837cb1e3906c4c0cfc9c1282..b2f86ea650f6c31c8c4d69836ebb6b638bc488fc 100644 (file)
@@ -5,7 +5,7 @@ includedir=@includedir@
 
 Name: pmt
 Description: The GNU Radio Polymorphic Type library
-Requires: gnuradio-omnithread
+Requires: 
 Version: @VERSION@
 Libs: -L${libdir} -lpmt
-Cflags: -I${includedir}
\ No newline at end of file
+Cflags: -I${includedir}
index 32e5210d5420063be07770e4df6fe4623dc2778a..a510f4e0be3fb031565495c13e3125c6e7c178fb 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2006,2008 Free Software Foundation, Inc.
+# Copyright 2006,2008,2009 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -21,7 +21,7 @@
 
 include $(top_srcdir)/Makefile.common
 
-AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(BOOST_CPPFLAGS) \
+AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) \
        $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
 
 TESTS = test_pmt
@@ -63,11 +63,11 @@ libpmt_la_SOURCES =                 \
        pmt_unv.cc                      
 
 # magic flags
-libpmt_la_LDFLAGS = $(NO_UNDEFINED)
+libpmt_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS)
 
 # link the library against the c++ standard library
 libpmt_la_LIBADD =                     \
-       $(OMNITHREAD_LA)                \
+       $(BOOST_THREAD_LIB)             \
        -lstdc++                        
 
 include_HEADERS =                      \
index 05d9c005bc6278407176e0d9cdb8c8251b4fedb2..05a7f590025e61aa02c960655b50f314e17d4aa5 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -34,8 +34,7 @@ ROUNDUP(size_t x, size_t stride)
 
 pmt_pool::pmt_pool(size_t itemsize, size_t alignment,
                   size_t allocation_size, size_t max_items)
-  : d_cond(&d_mutex),
-    d_itemsize(ROUNDUP(itemsize, alignment)),
+  : d_itemsize(ROUNDUP(itemsize, alignment)),
     d_alignment(alignment),
     d_allocation_size(std::max(allocation_size, 16 * itemsize)),
     d_max_items(max_items), d_n_items(0),
@@ -53,12 +52,12 @@ pmt_pool::~pmt_pool()
 void *
 pmt_pool::malloc()
 {
-  omni_mutex_lock l(d_mutex);
+  scoped_lock guard(d_mutex);
   item *p;
 
   if (d_max_items != 0){
     while (d_n_items >= d_max_items)
-      d_cond.wait();
+      d_cond.wait(guard);
   }
 
   if (d_freelist){     // got something?
@@ -98,12 +97,12 @@ pmt_pool::free(void *foo)
   if (!foo)
     return;
 
-  omni_mutex_lock l(d_mutex);
+  scoped_lock guard(d_mutex);
 
   item *p = (item *) foo;
   p->d_next = d_freelist;
   d_freelist = p;
   d_n_items--;
   if (d_max_items != 0)
-    d_cond.signal();
+    d_cond.notify_one();
 }
index dd63d44a6c3ec283260a303e36fba5ce3dc04059..8004a65e48dec0393af3dbb76aa1dadff71d8f84 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -22,8 +22,8 @@
 #define INCLUDED_PMT_POOL_H
 
 #include <cstddef>
-#include <gnuradio/omnithread.h>
 #include <vector>
+#include <boost/thread.hpp>
 
 /*!
  * \brief very simple thread-safe fixed-size allocation pool
@@ -37,8 +37,9 @@ class pmt_pool {
     struct item        *d_next;
   };
   
-  omni_mutex         d_mutex;
-  omni_condition      d_cond;
+  typedef boost::unique_lock<boost::mutex>  scoped_lock;
+  mutable boost::mutex                 d_mutex;
+  boost::condition_variable    d_cond;
   
   size_t             d_itemsize;
   size_t             d_alignment;