[niepce] Fix the thread / mutex usage by using the new API Require Glibmm 2.32



commit 7721d9889560d89e59be5ca2a4c81478685262b7
Author: Hub Figuiere <hub figuiere net>
Date:   Wed May 30 23:20:27 2012 -0700

    Fix the thread / mutex usage by using the new API
    Require Glibmm 2.32

 README                                   |    1 +
 configure.ac                             |    2 +-
 src/fwk/toolkit/notification.hpp         |    4 +-
 src/fwk/utils/db/sqlite/sqlitecnxdrv.cpp |   32 +++++++++++++++---------------
 src/fwk/utils/db/sqlite/sqlitecnxdrv.hpp |    4 +-
 src/fwk/utils/init.cpp                   |    5 +---
 src/fwk/utils/mtqueue.hpp                |    4 +-
 src/fwk/utils/thread.cpp                 |    2 +-
 src/fwk/utils/thread.hpp                 |    6 ++--
 src/fwk/utils/worker.hpp                 |   14 ++++++------
 10 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/README b/README
index 4445e7a..eb00dbc 100644
--- a/README
+++ b/README
@@ -21,6 +21,7 @@ To build is you need the following:
 A C++ compiler
 gtk+ 3.2
 cairo 1.1
+glibmm 2.32
 gtkmm 3.2
 giomm
 cairomm
diff --git a/configure.ac b/configure.ac
index b534dd5..a028a81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AC_SUBST(NIEPCE_VERSION)
 dnl all the library version.
 dnl if one is harcoded elsewhere, it is a bug
 LIBGIOMM_VERSION=2.16
-LIBGLIBMM_VERSION=2.4
+LIBGLIBMM_VERSION=2.32
 LIBGTKMM_VERSION=3.2
 LIBGNOMEUI_VERSION=2.0.0
 EXEMPI_VERSION=2.2.0
diff --git a/src/fwk/toolkit/notification.hpp b/src/fwk/toolkit/notification.hpp
index f960320..4c8c4ba 100644
--- a/src/fwk/toolkit/notification.hpp
+++ b/src/fwk/toolkit/notification.hpp
@@ -27,7 +27,7 @@
 #include <tr1/memory>
 #include <boost/any.hpp>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
 namespace fwk {
 
@@ -36,7 +36,7 @@ namespace fwk {
 	{
 	public:
 		typedef std::tr1::shared_ptr<Notification> Ptr;
-		typedef Glib::RecMutex mutex_t;
+	  typedef Glib::Threads::RecMutex mutex_t;
 
 		Notification(int _type)
 			: m_type(_type)
diff --git a/src/fwk/utils/db/sqlite/sqlitecnxdrv.cpp b/src/fwk/utils/db/sqlite/sqlitecnxdrv.cpp
index 94e4e93..490e542 100644
--- a/src/fwk/utils/db/sqlite/sqlitecnxdrv.cpp
+++ b/src/fwk/utils/db/sqlite/sqlitecnxdrv.cpp
@@ -211,7 +211,7 @@ namespace db { namespace sqlite {
 
 		SqliteCnxDrv::SqliteCnxDrv (sqlite3 *a_sqlite_handle)
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (a_sqlite_handle) ;
 			m_priv.reset (new Priv) ;
 			m_priv->sqlite.reset (a_sqlite_handle) ;
@@ -219,7 +219,7 @@ namespace db { namespace sqlite {
 
 		SqliteCnxDrv::~SqliteCnxDrv ()
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			close () ;
 			m_priv.reset(NULL);
 		}
@@ -235,7 +235,7 @@ namespace db { namespace sqlite {
 		const char*
 		SqliteCnxDrv::get_last_error () const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			if (m_priv && m_priv->sqlite) {
 				return sqlite3_errmsg (m_priv->sqlite.get ());
 			}
@@ -266,7 +266,7 @@ namespace db { namespace sqlite {
 		bool
 		SqliteCnxDrv::execute_statement (const SQLStatement &a_statement)
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 
 		  THROW_IF_FAIL (m_priv && m_priv->sqlite) ;
 		  DBG_OUT("sql string: %s", a_statement.to_string().c_str()) ;
@@ -370,7 +370,7 @@ namespace db { namespace sqlite {
 		bool
 		SqliteCnxDrv::should_have_data () const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			if (get_number_of_columns () > 0)
@@ -381,7 +381,7 @@ namespace db { namespace sqlite {
 		bool
 		SqliteCnxDrv::read_next_row ()
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 			if (m_priv->cur_stmt) {
 				if (m_priv->last_execution_result == SQLITE_DONE) {
@@ -404,7 +404,7 @@ namespace db { namespace sqlite {
 		unsigned int
 		SqliteCnxDrv::get_number_of_columns () const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 			if (!m_priv->cur_stmt)
 				return 0 ;
@@ -415,7 +415,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_content (uint32_t a_offset,
 										  fwk::Buffer &a_column_content) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
@@ -429,7 +429,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_content (uint32_t a_offset,
 										  int32_t &a_column_content) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
@@ -447,7 +447,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_content (uint32_t a_offset,
 										  int64_t &a_column_content) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
@@ -466,7 +466,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_content (uint32_t a_offset,
 										  double& a_column_content) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
 			int type = sqlite3_column_type (m_priv->cur_stmt, a_offset) ;
@@ -482,7 +482,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_content (uint32_t a_offset,
 										  std::string& a_column_content) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
@@ -506,7 +506,7 @@ namespace db { namespace sqlite {
 		SqliteCnxDrv::get_column_type (uint32_t a_offset,
 									   enum ColumnType &a_type) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
 			int type = sqlite3_column_type (m_priv->cur_stmt, a_offset) ;
@@ -538,7 +538,7 @@ namespace db { namespace sqlite {
 		bool
 		SqliteCnxDrv::get_column_name (uint32_t a_offset, fwk::Buffer &a_name) const
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 			RETURN_VAL_IF_FAIL (m_priv->check_offset (a_offset), false) ;
 			const char* name = sqlite3_column_name (m_priv->cur_stmt, a_offset) ;
@@ -551,7 +551,7 @@ namespace db { namespace sqlite {
 		void
 		SqliteCnxDrv::close ()
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv) ;
 
 			if (m_priv->sqlite) {
@@ -565,7 +565,7 @@ namespace db { namespace sqlite {
 		int64_t
 		SqliteCnxDrv::last_row_id()
 		{
-      Glib::RecMutex::Lock lock(m_mutex);
+      Glib::Threads::RecMutex::Lock lock(m_mutex);
 			THROW_IF_FAIL (m_priv);
 			if (m_priv->sqlite) {
 				return sqlite3_last_insert_rowid(m_priv->sqlite.get());
diff --git a/src/fwk/utils/db/sqlite/sqlitecnxdrv.hpp b/src/fwk/utils/db/sqlite/sqlitecnxdrv.hpp
index 4465106..8d01e61 100644
--- a/src/fwk/utils/db/sqlite/sqlitecnxdrv.hpp
+++ b/src/fwk/utils/db/sqlite/sqlitecnxdrv.hpp
@@ -29,7 +29,7 @@
 
 #include <boost/scoped_ptr.hpp>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
 #include "fwk/utils/db/iconnectiondriver.hpp"
 
@@ -44,7 +44,7 @@ class SqliteCnxDrv: public db::IConnectionDriver {
     struct Priv ;
     friend class SqliteCnxMgrDrv ;
     boost::scoped_ptr<Priv> m_priv ;
-    mutable Glib::RecMutex m_mutex;
+    mutable Glib::Threads::RecMutex m_mutex;
 
     //forbid copy
     SqliteCnxDrv (const SqliteCnxDrv &) ;
diff --git a/src/fwk/utils/init.cpp b/src/fwk/utils/init.cpp
index 0f8143f..5238541 100644
--- a/src/fwk/utils/init.cpp
+++ b/src/fwk/utils/init.cpp
@@ -18,7 +18,7 @@
  */
 
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 #include <giomm/init.h>
 
 
@@ -31,9 +31,6 @@ namespace utils {
 void init()
 {
   Gio::init();
-  if(!Glib::thread_supported()) {
-    Glib::thread_init();
-  }
 }
 
 
diff --git a/src/fwk/utils/mtqueue.hpp b/src/fwk/utils/mtqueue.hpp
index 76f161a..1f73bc2 100644
--- a/src/fwk/utils/mtqueue.hpp
+++ b/src/fwk/utils/mtqueue.hpp
@@ -23,7 +23,7 @@
 #define __FWK_UTILS_MTQUEUE_H__
 
 #include <deque>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
 namespace fwk {
 
@@ -36,7 +36,7 @@ namespace fwk {
 	class MtQueue
 	{
 	public:
-		typedef Glib::RecMutex mutex_t;
+	  typedef Glib::Threads::RecMutex mutex_t;
 		typedef T              value_type;
 
 		MtQueue();
diff --git a/src/fwk/utils/thread.cpp b/src/fwk/utils/thread.cpp
index 16e1837..c39c7b6 100644
--- a/src/fwk/utils/thread.cpp
+++ b/src/fwk/utils/thread.cpp
@@ -38,7 +38,7 @@ Thread::~Thread()
 
 void Thread::start()
 {
-    m_thrd = Glib::Thread::create(sigc::mem_fun(*this, &Thread::main), true);
+    m_thrd = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Thread::main));
 // TODO add this thread to a manager for task management.
 //		thrd->join();
 }
diff --git a/src/fwk/utils/thread.hpp b/src/fwk/utils/thread.hpp
index 0134dac..0067894 100644
--- a/src/fwk/utils/thread.hpp
+++ b/src/fwk/utils/thread.hpp
@@ -24,7 +24,7 @@
 
 #include <string>
 
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
 
 namespace fwk {
@@ -43,10 +43,10 @@ protected:
     void start();
     virtual void main() = 0;
     volatile bool m_terminated;
-    Glib::Thread * thread() const
+    Glib::Threads::Thread * thread() const
         { return m_thrd; }
 private:
-    Glib::Thread *       m_thrd;
+    Glib::Threads::Thread *       m_thrd;
 };
 
 }
diff --git a/src/fwk/utils/worker.hpp b/src/fwk/utils/worker.hpp
index da46f0d..3cb9828 100644
--- a/src/fwk/utils/worker.hpp
+++ b/src/fwk/utils/worker.hpp
@@ -51,8 +51,8 @@ protected:
     queue_t      m_tasks;
 private:
     virtual void execute(const T & _op) = 0;
-    Glib::Mutex m_q_mutex;
-    Glib::Cond m_wait_cond;
+    Glib::Threads::Mutex m_q_mutex;
+    Glib::Threads::Cond m_wait_cond;
 };
 
 template <class T>
@@ -67,7 +67,7 @@ Worker<T>::~Worker()
 {
     m_tasks.clear();
     {
-        Glib::Mutex::Lock lock(m_q_mutex);
+        Glib::Threads::Mutex::Lock lock(m_q_mutex);
         m_terminated = true;
         m_wait_cond.broadcast();
     }
@@ -85,7 +85,7 @@ void Worker<T>::main()
         {
             // make sure we terminate the thread before we unlock
             // the task queue.
-            Glib::Mutex::Lock lock(m_q_mutex);
+            Glib::Threads::Mutex::Lock lock(m_q_mutex);
             if(!m_tasks.empty()) {
                 op = m_tasks.pop();
             }
@@ -95,7 +95,7 @@ void Worker<T>::main()
             execute(op);
         }
 
-        Glib::Mutex::Lock lock(m_q_mutex);
+        Glib::Threads::Mutex::Lock lock(m_q_mutex);
         if(m_tasks.empty()) {
             m_wait_cond.wait(m_q_mutex);
         }
@@ -105,7 +105,7 @@ void Worker<T>::main()
 template <class T>
 void Worker<T>::schedule(const T & _op)
 {
-    Glib::Mutex::Lock lock(m_q_mutex);
+    Glib::Threads::Mutex::Lock lock(m_q_mutex);
     m_tasks.add(_op);
     m_wait_cond.broadcast();
 }
@@ -113,7 +113,7 @@ void Worker<T>::schedule(const T & _op)
 template <class T>
 void Worker<T>::clear()
 {
-    Glib::Mutex::Lock lock(m_q_mutex);
+    Glib::Threads::Mutex::Lock lock(m_q_mutex);
     m_tasks.clear();
 }
 



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