[glib/wip/gvariant-kdbus: 8/17] GVariant: refactor locking a bit more
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gvariant-kdbus: 8/17] GVariant: refactor locking a bit more
- Date: Wed, 3 Dec 2014 07:17:16 +0000 (UTC)
commit 87226d3b2fe626d4e914de1b1171010e95be30d9
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Nov 29 15:04:45 2014 -0500
GVariant: refactor locking a bit more
Change the internal g_variant_ensure_serialised() helper over to working
on unlocked instances and have it conditionally acquire the lock using
the utility function added in the last commit.
glib/gvariant-core.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/glib/gvariant-core.c b/glib/gvariant-core.c
index 0d50115..4ab4238 100644
--- a/glib/gvariant-core.c
+++ b/glib/gvariant-core.c
@@ -401,15 +401,11 @@ g_variant_fill_gvs (GVariantSerialised *serialised,
* that size and serialises the instance into the buffer. The
* 'children' array is then released and the instance is set to
* serialised form based on the contents of the buffer.
- *
- * The current thread must hold the lock on @value.
*/
static void
g_variant_ensure_serialised (GVariant *value)
{
- g_assert (value->state & STATE_LOCKED);
-
- if (~value->state & STATE_SERIALISED)
+ if (g_variant_lock_in_tree_form (value))
{
GBytes *bytes;
gpointer data;
@@ -423,6 +419,8 @@ g_variant_ensure_serialised (GVariant *value)
value->contents.serialised.data = g_bytes_get_data (bytes, NULL);
value->contents.serialised.bytes = bytes;
value->state |= STATE_SERIALISED;
+
+ g_variant_unlock (value);
}
}
@@ -826,9 +824,7 @@ g_variant_get_size (GVariant *value)
gconstpointer
g_variant_get_data (GVariant *value)
{
- g_variant_lock (value);
g_variant_ensure_serialised (value);
- g_variant_unlock (value);
return value->contents.serialised.data;
}
@@ -854,9 +850,7 @@ g_variant_get_data_as_bytes (GVariant *value)
gsize bytes_size;
gsize size;
- g_variant_lock (value);
g_variant_ensure_serialised (value);
- g_variant_unlock (value);
bytes_data = g_bytes_get_data (value->contents.serialised.bytes, &bytes_size);
data = value->contents.serialised.data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]