[Spice-devel] [spice-gtk v2] Introduce gtask-helper.[ch]
Eduardo Lima (Etrunko)
etrunko at redhat.com
Wed Mar 23 14:53:26 UTC 2016
On 23/03/16 09:04, Fabiano FidĂȘncio wrote:
> gtask-helper provide methods that can easily be used for returning in
> idle, as a few issues have been found in the GTask code used in
> spice-gtk due to a immediately return when a return in idle was
> expected. As examples of these issues, you can take a look on commits
> 7774b8c and e81d97c.
>
> Not all the functions introduced in gtask-helper.h are being used, but I
> still decided to add them for completeness reasons.
>
> Also, all the functions called in idle are the same that were being
> called in idle when using GSimpleAsyncResult. So, no issues should be
> found after this change and no behavior change should noticed.
>
> Signed-off-by: Fabiano FidĂȘncio <fidencio at redhat.com>
[snip]
> +++ b/src/gtask-helper.c
> @@ -0,0 +1,153 @@
> +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> +/*
> + Copyright (C) 2016 Red Hat, Inc.
> +
> + This library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.0 of the License, or (at your option) any later version.
> +
> + This library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with this library; if not, write to the Free Software
> + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> +*/
> +#include "config.h"
> +
> +#include "gtask-helper.h"
> +
> +typedef struct _GTaskHelperData
> +{
> + GTask *task;
> + GError *error;
> + gint integer;
> + gboolean boolean;
> + gpointer pointer;
> + GDestroyNotify destroy_notify_cb;
> +} GTaskHelperData;
> +
So, as far as I understand, you are trying to unify the behavior with
this data structure, but you are wasting quite a lot of memory here. I
don't know how memory critical this is, but, what do you think about
using a union and put all different data types inside of it instead?
That would also require you to declare a new struct for storing pointer
and destroy_notify_cb.
Just $0.02.
Regards, Etrunko
--
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com
More information about the Spice-devel
mailing list