From: Michael Tokarev <mjt@tls.msk.ru>
To: stefanha@redhat.com
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 3/3] glib: add compat wrapper for GStaticMutex
Date: Fri, 02 May 2014 15:08:07 +0400 [thread overview]
Message-ID: <53637C97.7040103@msgid.tls.msk.ru> (raw)
Stefan Hajnoczi:
> Avoid duplicating ifdefs for the deprecated GStaticMutex API by
> introducing compat_g_static_mutex_*() in glib-compat.h.
>
> GStaticMutex users should use the compat API to avoid dealing with
> deprecation.
To my taste this is a wrong(ish) approach.
GStaticMutex is nothing more than a pointer to GMutex wrapped in an internal
structure, and each function from g_static_mutex_* family first checks for
this pointer, whenever it is initialized, and calls g_mutex_new() if not.
So if there's a good place to actually init (allocate) a GMutex, it is better
to use it directly instead of checking for the init in every place.
(Note also that this checking itself may need a protection using a mutex,
to avoid 2 threads allocating the same GStaticMutex ;) -- this is done in
g_static_mutex_get_mutex_impl() inside glib).
But that's cosmetics.
More to the point is that this is re-introduction of old API for new program.
It'd be very nice if we were able to actually use the new API everywhere,
instead of re-introducing old API.
And this introduces some (light) wrapper #ifdefery too.
So we not only will use the old API in the code, we also will use wrappers
for almost everything. So it becomes rather clumsy.
It is, I think, better to try to switch to the new API as much as possible,
or to use our own types and wrappers instead, without resoting to use
foo_compat_deprecated_* (where "deprecated" part comes from staticmutex --
ie, instead of regular g_mutex_foo, we use g_compat_static_mutex_foo).
Other the bit of clumsiness, this should work.
> +/* GStaticMutex was deprecated in 2.32.0. Use the compat_g_static_mutex_*()
> + * wrappers to hide the GStaticMutex/GMutex distinction.
> + */
> +#if GLIB_CHECK_VERSION(2, 32, 0)
It is actually deprecated in 2.31, even if the glib docs says 2.32.
Probably not a big deal, as, I think, there's no 2.31 glib in the wild
due to bugs in there, so they had to quickly release 2.32.
Thanks,
/mjt
next reply other threads:[~2014-05-02 11:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 11:08 Michael Tokarev [this message]
2014-05-05 12:11 ` [Qemu-devel] [PATCH 3/3] glib: add compat wrapper for GStaticMutex Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2014-02-03 13:31 [Qemu-devel] [PATCH 0/3] glib: move compat functions into glib-compat.h Stefan Hajnoczi
2014-02-03 13:31 ` [Qemu-devel] [PATCH 3/3] glib: add compat wrapper for GStaticMutex Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53637C97.7040103@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.