[glib] g_object_weak_ref, g_object_add_weak_pointer: document non-thread-safety



commit 28c87a5594ef05a324a183d6d3271e6733abf908
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Tue Dec 6 11:37:45 2011 +0000

    g_object_weak_ref, g_object_add_weak_pointer: document non-thread-safety
    
    Transparent access to a weak pointer from the thread performing the
    weak -> strong conversion is incompatible with thread-safety: that
    thread will have to do something special. This is GNOME#548954.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=548954

 gobject/gobject.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 874096e..a8d4f9e 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -2462,6 +2462,10 @@ weak_refs_notify (gpointer data)
  * "weak references" because they allow you to safely hold a pointer
  * to an object without calling g_object_ref() (g_object_ref() adds a
  * strong reference, that is, forces the object to stay alive).
+ *
+ * Note that the weak references created by this method are not
+ * thread-safe: they cannot safely be used in one thread if the
+ * object's last g_object_unref() might happen in another thread.
  */
 void
 g_object_weak_ref (GObject    *object,
@@ -2546,6 +2550,11 @@ g_object_weak_unref (GObject    *object,
  * the pointer located at @weak_pointer_location is only valid during
  * the lifetime of @object. When the @object is finalized,
  * @weak_pointer will be set to %NULL.
+ *
+ * Note that as with g_object_weak_ref(), the weak references created by
+ * this method are not thread-safe: they cannot safely be used in one
+ * thread if the object's last g_object_unref() might happen in another
+ * thread.
  */
 void
 g_object_add_weak_pointer (GObject  *object, 



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