[glibmm] Glib::Threads::Private, Glib::Dispatcher: Delete Glib::DispatchNotifier.



commit ae0481bb3fe643938a5202428cb7662684ba430b
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon Mar 12 16:48:24 2012 +0100

    Glib::Threads::Private, Glib::Dispatcher: Delete Glib::DispatchNotifier.
    
    * glib/src/thread.hg: Add missing @deprecated.
    * glib/src/threads.hg: Add Private::replace(). Add documentation to Private.
    * glib/glibmm/dispatcher.cc: Use Private::replace() instead of set().
    Bug #671587.

 ChangeLog                 |    9 +++++++++
 glib/glibmm/dispatcher.cc |    4 ++--
 glib/src/thread.hg        |   16 ++++++++++++----
 glib/src/threads.hg       |   37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cbf96c0..e90d270 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-03-12  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Glib::Threads::Private, Glib::Dispatcher: Delete Glib::DispatchNotifier.
+
+	* glib/src/thread.hg: Add missing @deprecated.
+	* glib/src/threads.hg: Add Private::replace(). Add documentation to Private.
+	* glib/glibmm/dispatcher.cc: Use Private::replace() instead of set().
+	Bug #671587.
+
 2.31.20:
 
 2012-03-03  Murray Cumming  <murrayc murrayc com>
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index dcb3b2c..6bf8243 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -255,7 +255,7 @@ DispatchNotifier* DispatchNotifier::reference_instance(const Glib::RefPtr<MainCo
   if(!instance)
   {
     instance = new DispatchNotifier(context);
-    thread_specific_instance_.set(instance);
+    thread_specific_instance_.replace(instance);
   }
   else
   {
@@ -281,7 +281,7 @@ void DispatchNotifier::unreference_instance(DispatchNotifier* notifier)
     g_return_if_fail(instance->ref_count_ == 0); // could be < 0 if messed up
 
     // This causes deletion of the notifier object.
-    thread_specific_instance_.set(0);
+    thread_specific_instance_.replace(0);
   }
 }
 
diff --git a/glib/src/thread.hg b/glib/src/thread.hg
index 8c92e41..b1e6c7b 100644
--- a/glib/src/thread.hg
+++ b/glib/src/thread.hg
@@ -248,7 +248,7 @@ public:
    * @throw Glib::ThreadError
    *
    * @deprecated Use the simpler create() method instead, because all Threads 
-   * are now joinable, and bounds and priority parameters now have effect.
+   * are now joinable, and bounds and priority parameters now have no effect.
    */
   static Thread* create(const sigc::slot<void>& slot, unsigned long stack_size,
                         bool joinable, bool bound, ThreadPriority priority);
@@ -723,6 +723,10 @@ private:
 };
 
 
+/** Thread-local data pointer.
+ *
+ * @deprecated Use Glib::Threads::Private instead, which can be used statically.
+ */
 template <class T>
 struct StaticPrivate
 {
@@ -741,6 +745,10 @@ struct StaticPrivate
 #endif
 };
 
+/** Thread-local data pointer.
+ *
+ * @deprecated Use Glib::Threads::Private instead.
+ */
 template <class T>
 class Private
 {
@@ -1030,7 +1038,7 @@ void StaticPrivate<T>::delete_ptr(void* data)
   delete static_cast<T*>(data);
 }
 
-/** This is ony for use by glibmm itself.
+/** This is only for use by glibmm itself.
  */
 void* StaticPrivate_get_helper(GStaticPrivate *private_key);
 
@@ -1040,7 +1048,7 @@ T* StaticPrivate<T>::get()
   return static_cast<T*>(StaticPrivate_get_helper(&gobject_));
 }
 
-/** This is ony for use by glibmm itself.
+/** This is only for use by glibmm itself.
  */
 void StaticPrivate_set_helper(GStaticPrivate *private_key, gpointer data, GDestroyNotify notify);
 
@@ -1060,7 +1068,7 @@ void Private<T>::delete_ptr(void* data)
   delete static_cast<T*>(data);
 }
 
-/** This is ony for use by glibmm itself.
+/** This is only for use by glibmm itself.
  */
 GPrivate* GPrivate_new_helper(GDestroyNotify notify);
 
diff --git a/glib/src/threads.hg b/glib/src/threads.hg
index 44905a0..7f36988 100644
--- a/glib/src/threads.hg
+++ b/glib/src/threads.hg
@@ -442,18 +442,49 @@ private:
   Cond& operator=(const Cond&);
 };
 
+/** Thread-local data pointer.
+ *
+ * It is recommended that all instances of this class are statically allocated.
+ * The first time an instance is used (get(), set() or replace() is called)
+ * gtk+ allocates a scarce OS resource that cannot be deallocated.
+ */
 template <class T>
 class Private
 {
 public:
   typedef void (*DestructorFunc) (void*);
 
+  /** Deletes static_cast<T*>(data)
+   */
   static void delete_ptr(void* data);
 
+  /** Constructor.
+   *
+   * @param destructor_func Function pointer, or 0. If @a destructor_func is not 0
+   * and the stored data pointer is not 0, this function is called when replace()
+   * is called and when the thread exits.
+   */
   explicit inline Private(DestructorFunc destructor_func = &Private<T>::delete_ptr);
+
+  /** Gets the pointer stored in the calling thread.
+   *
+   * @return If no value has yet been set in this thread, 0 is returned.
+   */
   inline T* get();
+
+  /** Sets the pointer in the calling thread without calling <tt>destructor_func()</tt>.
+   */
   inline void set(T* data);
 
+  /** Sets the pointer in the calling thread and calls <tt>destructor_func()</tt>.
+   * If a function pointer (and not 0) was specified in the constructor, and
+   * the stored data pointer before the call to replace() is not 0, then
+   * <tt>destructor_func()</tt> is called with this old pointer value.
+   *
+   * @newin{2,32}
+   */
+  inline void replace(T* data);
+
   GPrivate* gobj() { return gobject_; }
 
 private:
@@ -749,6 +780,12 @@ void Private<T>::set(T* data)
   g_private_set(&gobject_, data);
 }
 
+template <class T> inline
+void Private<T>::replace(T* data)
+{
+  g_private_replace(&gobject_, data);
+}
+
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 // For some reason gmmproc thinks that g_iconv should be wrapped here.



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