g_object_notify_by_pspec() will emit the "notify" signal on the given
pspec, short-circuiting the hash table lookup needed by
g_object_notify(). The suggested and documented way of using
g_object_notify_by_pspec() is similar to the way of emitting signals
with their ID.
Emission tests (with no handler attached to the notify signal) show a
10-15% speedup over using g_object_notify().
https://bugzilla.gnome.org/show_bug.cgi?id=615425
This adds static markers and systemtap tapsets for:
* type creation
* object lifetimes (creation, ref, unref, dispose, finalize)
* signal creation and emission
Signal emissions and finalization marker have a corresponding
*_end (or *-end in dtrace) version that is when the corresponding
operation is finished.
https://bugzilla.gnome.org/show_bug.cgi?id=606044
The reason we need to enforce this is that the GTypeValueTable
documentation explicitly states that memory is memset to 0 when the
value_init function is called.
https://bugzilla.gnome.org/show_bug.cgi?id=603590
This works around the need to take a custom mutex twice and add the
object to a GSList of objects that are currently in construction for the
common case. Only when the constructor is overwritten do we use the
previous behavior and allow things like singleton objects.
The only slightly incompatible change is that previously, it was ok to
call g_object_set() on construct-only properties while the object was
initialized. This will now fail. If that behavior is needed, setting a
custom constructor that just chains up will reenable this functionality.
https://bugzilla.gnome.org/show_bug.cgi?id=557151
Store whether the object has a toggleref before decrementing the
refcount to prevent race condition when two threads simultaneously
try to unref an object with a refcount of 2.
Patch by Antoine Tremblay.
https://bugzilla.gnome.org/show_bug.cgi?id=551706
This avoids a bunch of code and makes construction of simple objects
faster.
Object construction performance improvement:
Non-Threaded Threaded
Simple: 14% 5%
Complex: -1.1% -2.2%
Other tests stable.
https://bugzilla.gnome.org/show_bug.cgi?id=557100
If the class has no properties there could be no notification anyway.
This is an important optimization for construction of simple objects.
Object construction performance improvement:
Non-Threaded Threaded
Simple: 84% 91%
Complex: -1.4% -0.6%
Other tests stable.
https://bugzilla.gnome.org/show_bug.cgi?id=557100
GLib users buildable with gcc 4.4. Patch by Jakub Jelinek.
* glib/gatomic.[hc]: Add G_GNUC_MAY_ALIAS to pointer arguments,
fix macro versions to only operate on objects of the same size.
* glib/gdataset.c:
* glib/gthread.[hc]:
* glib/gdatasetprivate.h: Remove unnecessary casts in
g_atomic_pointer_get calls.
svn path=/trunk/; revision=7875
2009-01-02 Behdad Esfahbod <behdad@gnome.org>
Bug 565136 – Gobject's "notify" signal parameters are wrong in gtk-doc
Patch from Andrzej Zaborowski
* gobject.c (g_object_do_class_init): Fix param order in docs.
svn path=/trunk/; revision=7759
2008-06-29 Björn Lindqvist <bjourne@gmail.com>
Bug 539626 – Update docstrings for g_object_freeze_notify and
g_object_thaw_notify
* gobject/gobject.c: Explain how the freeze count works.
svn path=/trunk/; revision=7102
2008-06-22 Michael Natterer <mitch@imendio.com>
* *.c: remove trailing whitespace from newly added gtk-doc
comments and reformatted some where they contained overly long or
ill-formatted lines.
svn path=/trunk/; revision=7090
2008-06-22 Michael Natterer <mitch@imendio.com>
* *.c: moved includes back to the top of the files (before gtk-doc
SECTION comments). Add "config.h" in all files and move system
included before glib includes. Remove trailing whitespace from
SECTION comments and did some reformatting where lines were overly
long, no documentation content was changed.
svn path=/trunk/; revision=7089
Tue Apr 3 12:34:14 2007 Tim Janik <timj@gtk.org>
* gobject.[hc]: invoke GObjectClass.constructed() only for newly
constructed objects, and invoke it while the notify queue is
still being frozen, after all CONSTRUCT* properties have been
set and before random other properties are being set.
* applied modified patch from Ryan Lortie to implement
GObjectClass.constructed() to fix#425324.
2007-04-02 Ryan Lortie <desrt@desrt.ca>
* gobject/gobject.h: Add 'constructed' vcall to GObjectClass.
* gobject/gobject.c (g_object_newv): call ->constructed() as last
step of object construction.
svn path=/trunk/; revision=5441
Tue Aug 29 13:27:33 2006 Tim Janik <timj@gtk.org>
* glib-mkenums.in: fixed to print usage and version info on STDOUT
(#322502).
* gobject.c (g_initially_unowned_init): restore ; after G_DEFINE_TYPE.
Wed Aug 23 10:35:32 2006 Tim Janik <timj@gtk.org>
* gobject.[hc]: changed return value of g_value_dup_object(), fixes#343292.
2006-08-23 Sven Neumann <sven@gimp.org>
* gobject/glib-genmarshal.[c1]: added new command-line option
"--internal" that can be used to let glib-genmarshal generate
internal functions using the G_GNUC_INTERNAL attribute (bug #346647).
Wed Aug 16 13:55:08 2006 Tim Janik <timj@imendio.com>
* gobject.c: conditionally thaw the notify queue after construction,
so we don't trigger warnings when trying to thaw an unfrozen singleton.
Tue Mar 7 17:09:07 2006 Tim Janik <timj@gtk.org>
* gobject.c (g_object_compat_control): added case3 to hand out the
original floating flag handler. required by gtk+ >= 2.10.
Thu Dec 22 14:59:24 2005 Tim Janik <timj@imendio.com>
* gvaluetypes.[hc]: implemented G_TYPE_GTPYE. applied patch
from matthias which implements GType accessors for GValue.
* gparamspecs.[hc]: applied patch from matthias which
implements G_TYPE_PARAM_GTYPE.
* gobject.[hc]:
GUnowned: introduced a new object type that has an initially
floating reference.
g_object_compat_control(): allow setting of a floating flag handler.
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().
Mon Aug 1 23:00:42 2005 Tim Janik <timj@imendio.com>
* gclosure.c: turned all modifications to the first 32 integer bits in a
closure into atomic accesses. wrapped write accesses into special macros
to keep the atomic modification logic in a single place. comment cleanups.
* gclosure.h: made all atomicly accessed closure fields volatile.
* gobject.h: made ref_count field volatile.
Sun Jul 31 02:04:23 2005 Tim Janik <timj@gtk.org>
* gobject.c: use g_datalist_set_flags() and g_datalist_unset_flags() to
allow proper locking around &qdata modifications.
Sat Jul 30 21:10:26 2005 Tim Janik <timj@gtk.org>
* gobject.c: reverted notify_mutex introduction, since this prevents
parallelized setting of object properties on different objects, and
serves no apparent purpose (to me at least).
g_object_real_dispose(): removed non-atomic reference count
modifications.
g_object_unref(): make sure the closures array is destroyed when
destroying signal handlers.
* gparam.c: cosmetic changes.
* gsignal.c: comment fixup. allow 16bit blocking count.
* gsignal.c: reverted GClosure related changes.
* gclosure.c: reverted premature commit of atomic reference
counting attempt.
2005-07-15 Matthias Clasen <mclasen@redhat.com>
Make refcounting threadsafe by using atomic
operations. (#166020, Wim Taymans)
* gobject.c: Use a recursive lock to protect the
notify queue.
(g_object_unref): Get rid of g_object_last_unref and
do the last unref handling in g_object_unref.
(g_object_ref, g_object_unref): Use atomic operations.
* gsignal.c (struct _HandlerMatch): Use a full integer
for the ref_count field.
(handler_ref, handler_unref_R): Use atomic operations.
* gparam.c (g_param_spec_ref, g_param_spec_unref):
Use atomic operations instead of a lock to make the
refcounting threadsafe.
* gclosure.c (g_closure_ref, g_closure_unref): Use atomic
operations. This is more complicated here, since the
refcount is stored in a bitfield, so we also have
to access all other bitfield members atomically.
* gsignal.c (handlers_find): Read the meta_marshal flag
of the closure atomically.
* tests/Makefile.am (SUBDIRS): Add tests/refcount
* configure.in: Add tests/refcount
* tests/refcount/properties.c: Test property changes
from multiple threads.
* tests/refcount/signals.c: Test signal emission from
multiple threads.
* tests/refcount/objects.c: Test refcounting from
multiple threads.
* tests/refcount/objects2.c:
* tests/refcount/properties2.c: Tests to measure the
overhead of threadsafe refcounting.
* glib/giochannel.c (g_io_channel_ref, g_io_channel_unref):
Use atomic operations to make refcounting
threadsafe. (#166020, Wim Taymans)
2005-05-05 Owen Taylor <otaylor@redhat.com>
* gobject.[ch] gobject.symbols: Add
g_object_add/remove_toggle_ref() functions to get notification
when a reference count is the last remaining reference; this
enables better memory management for language bindings.
(http://mail.gnome.org/archives/gtk-devel-list/2005-April/msg00095.html)
2005-05-05 Owen Taylor <otaylor@redhat.com>
* glib/gdataset.[ch] glib/gdatasetprivate.h: Add
g_datalist_set/unset_flags(), g_datalist_get_flags() functions
to squeeze some bits into a GDataSet... this is needed for
efficient implementation of toggle references in GObject.
* tests/gobject/references.c tests/gobject/Makefile.am:
Add a test case for weak and toggle references.
* glib/gfileutils.[ch]: Rename g_file_replace() back
to g_file_set_contents().
* glib/glib.symbols: Update.
2005-05-05 Owen Taylor <otaylor@redhat.com>
* glib/Makefile.am glib/glib-sections.txt gobject/gobject-sections.txt:
Update
* gobject/tmpl/objects.sgml: Document toggle-references.
2005-03-14 Matthias Clasen <mclasen@redhat.com>
* abicheck.sh: Make work again.
* gsourceclosure.c: Fix a typo.
Make PLT-reduction work with gcc4, and don't include
everything in gobjectalias.h:
* gobject.symbols: Group symbols by header and source
file.
* makegobjectalias.pl: Protect definitions by the same
preprocessor symbols used to guard the headers. Move
the alias declarations to a separate file which is
produced when calling makegalias.pl -def
* Makefile.am (gobjectaliasdef.c): Add a rule to
build this file.
* *.c: Include gobjectalias.h after the other i
GLib headers, include gobjectaliasdef.c at the bottom.
2004-09-16 Matthias Clasen <mclasen@redhat.com>
Implement the same PLT reduction technique used in GTK+:
* Makefile.am: Generate gobjectalias.h from gobject.symbols.
(BUILT_SOURCES): Add gobjectalias.h.
* makegobjectalias.pl: Script to generate gobjectalias.h.
* *.c: Include gobjectalias.h
Sat Nov 29 14:57:20 2003 Tim Janik <timj@gtk.org>
* gobject.c: fix g_object_set() whithin _init() implementations
not working for construct-only properties.
(g_object_init): make the object enter a construct_objects list.
(g_object_newv): remove object from construct_objects after creation.
(g_object_set_valist):
(g_object_set_property): allow construct-only properties for
objects which are in construct_objects.
Thu Nov 27 17:53:52 2003 Tim Janik <timj@gtk.org>
* gtype.[hc]:
(g_type_class_peek_static): variant of class_peek() which works for
static types only.
* gobject.c:
(g_object_do_class_init): make ::notify a run-action signal.
(g_object_newv): use g_type_class_peek_static() by default to
speed up common code path (trades two write-locks for one read-lock).
(g_object_disconnect):
(g_object_connect): allow signal specification words to be
seperated by '-'.
(g_object_set_valist):
(g_object_new_valist): don't leak values.
(g_object_get_property): check property for readability.
(g_object_set_property): check property for writability and to
not be construct-only.
(g_object_set_valist): check property to not be construct-only.
Tue Oct 14 17:40:19 2003 Owen Taylor <otaylor@redhat.com>
* gparamspecs.[ch]: Add a new GParamSpecOverride type
that is a pointer to a different paramspec in a parent
class or interface.
* gparam.[ch]: Add g_paramspec_get_redirect_target()
which follows GParamSpecOverride to the real property.
Make g_param_spec_pool_list() hand redirections,
properties on interfaces.
* gobject.[ch] gobjectnotifyqueue.c: Add
g_object_interface_install_property,
g_object_interface_find_property,
g_object_interface_list_properties(). Redirect virtually all
publically exposed GParamSpec's to the redirect target if
any. (->constructor is the exception.)
(#105894)