[glibmm] Glib::Threads:[Rec]Mutex: Add wrap() functions.



commit 704e80a43e17278ae8b3d9aa61452f51ea8906e6
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Jul 26 09:50:40 2012 +0200

    Glib::Threads:[Rec]Mutex: Add wrap() functions.
    
    * glib/src/threads.[hg|ccg]: Add Mutex* wrap(GMutex*) and
    RecMutex* wrap(GRecMutex*). Bug #483790.

 ChangeLog            |    7 +++++++
 glib/src/threads.ccg |   10 ++++++++++
 glib/src/threads.hg  |   25 ++++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 51b802f..4f8f4b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-07-26  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Glib::Threads:[Rec]Mutex: Add wrap() functions.
+
+	* glib/src/threads.[hg|ccg]: Add Mutex* wrap(GMutex*) and
+	RecMutex* wrap(GRecMutex*). Bug #483790.
+
 2012-07-22  Krzesimir Nowak  <qdlacz gmail com>
 
 	Properly wrap g_key_file_load_from_dirs().
diff --git a/glib/src/threads.ccg b/glib/src/threads.ccg
index 7133a3d..611c3e0 100644
--- a/glib/src/threads.ccg
+++ b/glib/src/threads.ccg
@@ -135,6 +135,11 @@ void Mutex::unlock()
   g_mutex_unlock(&gobject_);
 }
 
+Mutex* wrap(GMutex* gobject)
+{
+  return reinterpret_cast<Mutex*>(gobject);
+}
+
 /**** Glib::RecMutex *******************************************************/
 
 RecMutex::RecMutex()
@@ -162,6 +167,11 @@ void RecMutex::unlock()
   g_rec_mutex_unlock(&gobject_);
 }
 
+RecMutex* wrap(GRecMutex* gobject)
+{
+  return reinterpret_cast<RecMutex*>(gobject);
+}
+
 /**** Glib::RWLock ***************************************************/
 
 void RWLock::reader_lock()
diff --git a/glib/src/threads.hg b/glib/src/threads.hg
index 7f36988..5b9323c 100644
--- a/glib/src/threads.hg
+++ b/glib/src/threads.hg
@@ -222,7 +222,19 @@ private:
   Mutex::Lock& operator=(const Mutex::Lock&);
 };
 
-//TODO: Docuemenation
+/** A C++ wrapper for the C object.
+ * Do not use operator delete on the returned pointer. If the caller owns the
+ * GMutex object, the caller must destroy it in the same way as if this function
+ * had not been called.
+ *
+ * @param gobject The C instance.
+ * @result The GMutex* cast to a Glib::Threads::Mutex*.
+ *
+ * @relates Glib::Threads::Mutex
+ */
+Mutex* wrap(GMutex* gobject);
+
+//TODO: Documentation
 class RecMutex
 {
 public:
@@ -272,6 +284,17 @@ private:
   RecMutex::Lock& operator=(const RecMutex::Lock&);
 };
 
+/** A C++ wrapper for the C object.
+ * Do not use operator delete on the returned pointer. If the caller owns the
+ * GRecMutex object, the caller must destroy it in the same way as if this function
+ * had not been called.
+ *
+ * @param gobject The C instance.
+ * @result The GRecMutex* cast to a Glib::Threads::RecMutex*.
+ *
+ * @relates Glib::Threads::RecMutex
+ */
+RecMutex* wrap(GRecMutex* gobject);
 
 //TODO: Documentation
 class RWLock



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