+Wed Nov 23 18:01:46 2005 Tim Janik <timj@imendio.com>
+
+ * gobject.[hc]: added floating reference count.
+ g_object_is_floating():
+ g_object_ref_sink(): new functions to deal with floating references.
+ g_object_force_floating(): new funciton for object implementations
+ to set the floating flag.
+
+ * gobject.c (g_object_init): make objects initially floating.
+
+Wed Nov 23 17:58:13 2005 Tim Janik <timj@gtk.org>
+
+ * gparam.[hc]: added g_param_spec_ref_sink().
+
Wed Nov 23 13:36:02 2005 Tim Janik <timj@gtk.org>
* gboxed.[hc]: minor cleanups, implemented G_TYPE_HASH_TABLE.
#define OBJECT_HAS_TOGGLE_REF_FLAG 0x1
#define OBJECT_HAS_TOGGLE_REF(object) \
- ((G_DATALIST_GET_FLAGS(&(object)->qdata) & OBJECT_HAS_TOGGLE_REF_FLAG) != 0)
+ ((G_DATALIST_GET_FLAGS (&(object)->qdata) & OBJECT_HAS_TOGGLE_REF_FLAG) != 0)
+#define OBJECT_FLOATING_FLAG 0x2
/* --- signals --- */
{
object->ref_count = 1;
g_datalist_init (&object->qdata);
+ g_object_force_floating (object);
/* freeze object's notification queue, g_object_newv() preserves pairedness */
g_object_notify_queue_freeze (object, &property_notify_context);
weak_pointer_location);
}
+gboolean
+g_object_is_floating (gpointer _object)
+{
+ GObject *object = _object;
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
+ return ((gsize) g_atomic_pointer_get (&object->qdata) & OBJECT_FLOATING_FLAG) != 0;
+}
+
+gpointer
+g_object_ref_sink (gpointer _object)
+{
+ GObject *object = _object;
+ gpointer oldvalue;
+ g_return_val_if_fail (G_IS_OBJECT (object), object);
+ g_return_val_if_fail (object->ref_count >= 1, object);
+ g_object_ref (object);
+ do
+ {
+ oldvalue = g_atomic_pointer_get (&object->qdata);
+ }
+ while (!g_atomic_pointer_compare_and_exchange ((void**) &object->qdata, oldvalue,
+ (gpointer) ((gsize) oldvalue & ~(gsize) OBJECT_FLOATING_FLAG)));
+ if ((gsize) oldvalue & OBJECT_FLOATING_FLAG)
+ g_object_unref (object);
+ return object;
+}
+
+void
+g_object_force_floating (GObject *object)
+{
+ gpointer oldvalue;
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (object->ref_count >= 1);
+ do
+ {
+ oldvalue = g_atomic_pointer_get (&object->qdata);
+ }
+ while (!g_atomic_pointer_compare_and_exchange ((void**) &object->qdata, oldvalue,
+ (gpointer) ((gsize) oldvalue | OBJECT_FLOATING_FLAG)));
+}
+
typedef struct {
GObject *object;
guint n_toggle_refs;
void g_object_notify (GObject *object,
const gchar *property_name);
void g_object_thaw_notify (GObject *object);
+gboolean g_object_is_floating (gpointer object);
+gpointer g_object_ref_sink (gpointer object);
gpointer g_object_ref (gpointer object);
void g_object_unref (gpointer object);
void g_object_weak_ref (GObject *object,
/*< protected >*/
+void g_object_force_floating (GObject *object);
void g_object_run_dispose (GObject *object);
g_object_newv
g_object_new_valist
g_object_notify
+g_object_is_floating
+g_object_ref_sink
+g_object_force_floating
g_object_ref
+g_object_unref
g_object_remove_weak_pointer
g_object_run_dispose
g_object_set G_GNUC_NULL_TERMINATED
g_object_steal_data
g_object_steal_qdata
g_object_thaw_notify
-g_object_unref
g_object_watch_closure
g_object_weak_ref
g_object_weak_unref
g_param_spec_internal
g_param_type_register_static
g_param_spec_ref
+g_param_spec_ref_sink
g_param_spec_unref
g_param_spec_sink
g_param_spec_steal_qdata
g_param_spec_unref (pspec);
}
+GParamSpec*
+g_param_spec_ref_sink (GParamSpec *pspec)
+{
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
+ g_return_val_if_fail (pspec->ref_count > 0, NULL);
+
+ g_param_spec_ref (pspec);
+ g_param_spec_sink (pspec);
+ return pspec;
+}
+
G_CONST_RETURN gchar*
g_param_spec_get_name (GParamSpec *pspec)
{
GParamSpec* g_param_spec_ref (GParamSpec *pspec);
void g_param_spec_unref (GParamSpec *pspec);
void g_param_spec_sink (GParamSpec *pspec);
+GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec);
gpointer g_param_spec_get_qdata (GParamSpec *pspec,
GQuark quark);
void g_param_spec_set_qdata (GParamSpec *pspec,