[evolution-ews/gnome-3-4] Bug #680683 - Do not block factory's main thread
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-4] Bug #680683 - Do not block factory's main thread
- Date: Fri, 27 Jul 2012 08:35:07 +0000 (UTC)
commit a2d6bc4628cc7b89ea15eacac4b9a12805dabd3e
Author: Milan Crha <mcrha redhat com>
Date: Fri Jul 27 10:34:42 2012 +0200
Bug #680683 - Do not block factory's main thread
src/calendar/e-cal-backend-ews.c | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index e7e93e8..42af8e5 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -3465,8 +3465,8 @@ exit:
g_object_unref (cbews);
}
-static gboolean
-ews_start_sync (gpointer data)
+static gpointer
+ews_start_sync_thread (gpointer data)
{
ECalBackendEws *cbews;
ECalBackendEwsPrivate *priv;
@@ -3487,6 +3487,22 @@ ews_start_sync (gpointer data)
EWS_MAX_FETCH_COUNT,
ews_cal_sync_items_ready_cb,
NULL, g_object_ref (cbews));
+
+ g_object_unref (cbews);
+
+ return NULL;
+}
+
+static gboolean
+ews_start_sync (gpointer data)
+{
+ GThread *thread;
+
+ /* run the actual operation in thread,
+ to not block main thread of the factory */
+ thread = g_thread_new (NULL, ews_start_sync_thread, g_object_ref (data));
+ g_thread_unref (thread);
+
return TRUE;
}
@@ -3499,14 +3515,12 @@ ews_cal_start_refreshing (ECalBackendEws *cbews)
PRIV_LOCK (priv);
- if (!priv->refresh_timeout &&
- priv->is_online &&
- priv->cnc) {
- ews_start_sync (cbews);
- priv->refresh_timeout = g_timeout_add_seconds
- (REFRESH_INTERVAL,
- (GSourceFunc) ews_start_sync,
- cbews);
+ if (!priv->refresh_timeout &&
+ priv->is_online &&
+ priv->cnc) {
+ ews_start_sync (cbews);
+ priv->refresh_timeout = g_timeout_add_seconds (
+ REFRESH_INTERVAL, (GSourceFunc) ews_start_sync, cbews);
}
PRIV_UNLOCK (priv);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]