GDBusConnection: replace is_initialized with an atomic flag
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 21 Oct 2011 15:02:22 +0000 (16:02 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 21 Oct 2011 15:02:22 +0000 (16:02 +0100)
commit245d68be6ff0104783ce0b2d4bc0a139f09e0c34
tree62213df75fba9e69135ff05a1e09e38628dea2e1
parente1a481ec0ab4b727632e9ef5d74e001318ab84a2
GDBusConnection: replace is_initialized with an atomic flag

The comment implied that even failed initialization would set
is_initialized = TRUE, but this wasn't the case - failed initialization
would only set initialization_error, and it was necessary to check both.

It turns out the documented semantics are nicer than the implemented
semantics, since this lets us use atomic operations, which are also
memory barriers, to avoid needing separate memory barriers or locks
for initialization_error (and other members that are read-only after
construction).

I expect to need more than one atomically-accessed flag to fix thread
safety, so instead of a minimal implementation I've turned is_initialized
into a flags word.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661992
Reviewed-by: David Zeuthen <davidz@redhat.com>
gio/gdbusconnection.c