summaryrefslogtreecommitdiffstats
path: root/src/channel-main.c
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2016-03-23 03:50:40 +0100
committerFabiano Fidêncio <fidencio@redhat.com>2016-03-23 04:22:37 +0100
commit0fa5895d6218269cce31315c36cb588c72a52fe0 (patch)
treec814ae20419b8c9715c93971d1a69f84aa0837eb /src/channel-main.c
parentf973df7e54b296f5cd2eca7498aea285a84ab007 (diff)
downloadspice-gtk-wip/gtask-helper.tar.gz
spice-gtk-wip/gtask-helper.tar.xz
spice-gtk-wip/gtask-helper.zip
Introduce gtask-helper.[ch]wip/gtask-helper
As noticed, GTask's heurestic for return a task in idle or immediately doesn't work when using Coroutine and that's okay, we just need to do the idle ourself. And in order to avoid code duplication, let's introduce and make usage of the new g_task_helper_return_* functions. These functions match exactly with the existing g_task_return_* functions and the only difference is that they return on idle instead of returning immediately. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'src/channel-main.c')
-rw-r--r--src/channel-main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/channel-main.c b/src/channel-main.c
index 1c19de1..9252777 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -21,6 +21,8 @@
#include <spice/vd_agent.h>
#include <glib/gstdio.h>
+#include "gtask-helper.h"
+
#include "spice-client.h"
#include "spice-common.h"
#include "spice-marshal.h"
@@ -923,7 +925,7 @@ static gboolean flush_foreach_remove(gpointer key G_GNUC_UNUSED,
{
gboolean success = GPOINTER_TO_UINT(user_data);
GTask *result = value;
- g_task_return_boolean(result, success);
+ g_task_helper_return_boolean(result, success);
return TRUE;
}
@@ -946,7 +948,7 @@ static void file_xfer_flush_async(SpiceMainChannel *channel, GCancellable *cance
was_empty = g_queue_is_empty(c->agent_msg_queue);
if (was_empty) {
- g_task_return_boolean(task, TRUE);
+ g_task_helper_return_boolean(task, TRUE);
g_object_unref(task);
return;
}
@@ -981,7 +983,7 @@ static void agent_send_msg_queue(SpiceMainChannel *channel)
task = g_hash_table_lookup(c->flushing, out);
if (task) {
/* if there's a flush task waiting for this message, finish it */
- g_task_return_boolean(task, TRUE);
+ g_task_helper_return_boolean(task, TRUE);
g_hash_table_remove(c->flushing, out);
}
}
@@ -1790,9 +1792,9 @@ static void file_xfer_close_cb(GObject *object,
self->priv->user_data);
if (self->priv->error) {
- g_task_return_error(task, self->priv->error);
+ g_task_helper_return_error(task, self->priv->error);
} else {
- g_task_return_boolean(task, TRUE);
+ g_task_helper_return_boolean(task, TRUE);
if (spice_util_get_debug()) {
gint64 now = g_get_monotonic_time();
gchar *basename = g_file_get_basename(self->priv->file);