[glibmm] threadpool example: Use Mutex instead of StaticMutex.



commit acf84955b9a86597e4675a0edc0848851ecafba7
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Oct 26 22:27:48 2011 +0200

    threadpool example: Use Mutex instead of StaticMutex.
    
    * examples/thread/threadpool.cc: The advantage of StaticMutex was that
    it would silently do nothing if threads were not initialized. That
    was never a useful distinction in this example anyway.
    Also remove the deprecated thread_init() call.
    * glib/src/thread.ccg: Mutex: Add a TODO about not using the deprecated
    API.

 ChangeLog                     |   11 +++++++++++
 examples/thread/threadpool.cc |    4 +---
 glib/src/thread.ccg           |    2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bab29b7..ab3ff14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-26  Murray Cumming  <murrayc murrayc com>
 
+	threadpool example: Use Mutex instead of StaticMutex.
+
+	* examples/thread/threadpool.cc: The advantage of StaticMutex was that
+	it would silently do nothing if threads were not initialized. That
+	was never a useful distinction in this example anyway.
+	Also remove the deprecated thread_init() call.
+	* glib/src/thread.ccg: Mutex: Add a TODO about not using the deprecated
+	API.
+
+2011-10-26  Murray Cumming  <murrayc murrayc com>
+
   Fix the deprecation ifdefs.
   
 	* glib/src/thread.hg: Move the deprecation ifdefs to avoid affecting 
diff --git a/examples/thread/threadpool.cc b/examples/thread/threadpool.cc
index 542c524..6ee3847 100644
--- a/examples/thread/threadpool.cc
+++ b/examples/thread/threadpool.cc
@@ -9,7 +9,7 @@
 namespace
 {
 
-Glib::StaticMutex mutex = GLIBMM_STATIC_MUTEX_INIT;
+Glib::Mutex mutex;
 
 void print_char(char c)
 {
@@ -31,8 +31,6 @@ void print_char(char c)
 
 int main(int, char**)
 {
-  Glib::thread_init();
-
   Glib::ThreadPool pool (10);
 
   for(char c = 'a'; c <= 'z'; ++c)
diff --git a/glib/src/thread.ccg b/glib/src/thread.ccg
index c50101c..bc27592 100644
--- a/glib/src/thread.ccg
+++ b/glib/src/thread.ccg
@@ -217,7 +217,7 @@ StaticMutex::operator Mutex&()
 
 Mutex::Mutex()
 :
-  gobject_ (g_mutex_new())
+  gobject_ (g_mutex_new()) //TODO: Use a statically-allocated GMutext instead, with g_mutex_init().
 {}
 
 Mutex::~Mutex()



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