Patch: fast folders list store operation



	Hi,

	This patch improves the responsiveness of folder list store, avoiding
queuing refresh and get folders operations caused by the list store.

	This improves a lot the user perceived speed in modest, as it'll avoid
waits on closing and opening again the folders view.

Changes:
	* Add API to avoid recursing list store if disposed. Also, in folder
list store only do refresh on account, but anyway still use delayed
refresh.
	* Avoid accumulating poke status. We can only have one ongoing poke
status request.
	* Don't fflush store summary on saving it. It's a cache, we can affort
data lose.
	* Camel queue response priority set to "G_PRIORITY_LOW" to avoid
disturbing processing user interaction responses.




-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/libtinymail-camel/camel-lite/camel/camel-store-summary.c b/libtinymail-camel/camel-lite/camel/camel-store-summary.c
index 9ec3c20..abba055 100644
--- a/libtinymail-camel/camel-lite/camel/camel-store-summary.c
+++ b/libtinymail-camel/camel-lite/camel/camel-store-summary.c
@@ -487,7 +487,7 @@ camel_store_summary_save(CamelStoreSummary *s, CamelException *ex)
 		((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_save(s, out, info);
 	}
 
-	if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
+	if (fflush (out) != 0) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM_IO_WRITE,
 			_("Error storing the store summary"));
 		i = errno;
diff --git a/libtinymail-camel/tny-camel-folder-priv.h b/libtinymail-camel/tny-camel-folder-priv.h
index 692287d..1eef15e 100644
--- a/libtinymail-camel/tny-camel-folder-priv.h
+++ b/libtinymail-camel/tny-camel-folder-priv.h
@@ -56,6 +56,7 @@ struct _TnyCamelFolderPriv
 	CamelException load_ex;
 	GList *obs, *sobs;
 	gboolean cant_reuse_iter;
+	gboolean ongoing_poke_status;
 };
 
 CamelFolder* _tny_camel_folder_get_camel_folder (TnyCamelFolder *self);
diff --git a/libtinymail-camel/tny-camel-folder.c b/libtinymail-camel/tny-camel-folder.c
index 7532166..432c0c6 100644
--- a/libtinymail-camel/tny-camel-folder.c
+++ b/libtinymail-camel/tny-camel-folder.c
@@ -6055,6 +6055,8 @@ tny_camel_folder_poke_status_callback (gpointer data)
 	TnyFolderChange *change = NULL;
 	TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
 
+	priv->ongoing_poke_status = FALSE;
+
 	if (info->cancelled)
 		return FALSE;
 
@@ -6137,8 +6139,16 @@ static void
 tny_camel_folder_poke_status_default (TnyFolder *self)
 {
 	TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
-	CamelStore *store = priv->store;
-	PokeStatusInfo *info = g_slice_new (PokeStatusInfo);
+	CamelStore *store;
+	PokeStatusInfo *info;
+
+	if (priv->ongoing_poke_status)
+		return;
+
+	store = priv->store;
+	info = g_slice_new (PokeStatusInfo);
+
+	priv->ongoing_poke_status = TRUE;
 
 	info->do_status = FALSE;
 	/* Thread reference */
@@ -6781,6 +6791,8 @@ tny_camel_folder_instance_init (GTypeInstance *instance, gpointer g_class)
 	priv->obs_lock = g_new0 (GStaticRecMutex, 1);
 	g_static_rec_mutex_init (priv->obs_lock);
 
+	priv->ongoing_poke_status = FALSE;
+
 	return;
 }
 
diff --git a/libtinymail-camel/tny-camel-queue.c b/libtinymail-camel/tny-camel-queue.c
index eae6e95..3a4c028 100644
--- a/libtinymail-camel/tny-camel-queue.c
+++ b/libtinymail-camel/tny-camel-queue.c
@@ -237,12 +237,12 @@ tny_camel_queue_thread_main_func (gpointer user_data)
 
 			if (deleted) {
 
-				g_idle_add_full (G_PRIORITY_DEFAULT, 
+				g_idle_add_full (G_PRIORITY_LOW, 
 					perform_cancel_callback, item, 
 					perform_cancel_destroyer);
 			} else {
 
-				g_idle_add_full (G_PRIORITY_DEFAULT, 
+				g_idle_add_full (G_PRIORITY_LOW, 
 					perform_callback, item, 
 					perform_destroyer);
 			}
diff --git a/libtinymailui-gtk/tny-gtk-folder-list-store.c b/libtinymailui-gtk/tny-gtk-folder-list-store.c
index 91f3f2c..c28e351 100644
--- a/libtinymailui-gtk/tny-gtk-folder-list-store.c
+++ b/libtinymailui-gtk/tny-gtk-folder-list-store.c
@@ -239,7 +239,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 	do_poke_status = info->do_poke_status;
 	g_slice_free (_RefreshInfo, info);
 
-	if (cancelled || err) {
+	if (cancelled || err || self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DISPOSED) {
 		g_warning ("%s Error getting the folders", __FUNCTION__);
 		if (self->progress_count > 0) {
 			self->progress_count--;
@@ -356,7 +356,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 				new_info->do_poke_status = do_poke_status;
 				tny_folder_store_get_folders_async (folder_store,
 								    folders, NULL, 
-								    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
+								    FALSE,
 								    recurse_folders_async_cb,
 								    NULL, new_info);
 				g_object_unref (folders);
@@ -397,7 +397,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 				new_info->do_poke_status = do_poke_status;
 				tny_folder_store_get_folders_async (folder_store,
 								    folders, NULL, 
-								    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
+								    FALSE,
 								    recurse_folders_async_cb,
 								    NULL, new_info);
 				g_object_unref (folders);
@@ -515,7 +515,7 @@ get_folders_cb (TnyFolderStore *fstore, gboolean cancelled, TnyList *list, GErro
 	/* But first, let's find-back that damn account so that we have the
 	 * actual iter behind it in the model. */
 
-	if (gtk_tree_model_get_iter_first (model, &iter))
+	if ((!(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DISPOSED)) && gtk_tree_model_get_iter_first (model, &iter))
 	  do 
 	  {
 		GObject *citem;
@@ -554,7 +554,7 @@ get_folders_cb (TnyFolderStore *fstore, gboolean cancelled, TnyList *list, GErro
 		new_info->do_poke_status = do_poke_status;
 		tny_folder_store_get_folders_async (fstore,
 						    folders, NULL, 
-						    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
+						    FALSE,
 						    recurse_folders_async_cb,
 						    NULL, new_info);
 		g_object_unref (folders);
@@ -585,6 +585,9 @@ constatus_do_refresh (TnyAccount *account, TnyConnectionStatus status, TnyGtkFol
 	if (!self || !TNY_IS_GTK_FOLDER_LIST_STORE (self))
 		return;
 
+	if (self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DISPOSED)
+		return;
+
 	/* This callback handler deals with connection status changes. In case
 	 * we got connected, we can expect that, at least sometimes, new folders
 	 * might have arrived. We'll need to scan for those, so we'll recursively
@@ -605,7 +608,7 @@ constatus_do_refresh (TnyAccount *account, TnyConnectionStatus status, TnyGtkFol
 
 	tny_folder_store_get_folders_async (TNY_FOLDER_STORE (account),
 					    list, self->query,
-					    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
+					    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),  
 					    get_folders_cb, NULL, info);
 
 	return;
@@ -859,6 +862,16 @@ tny_gtk_folder_list_store_new_with_flags (TnyFolderStoreQuery *query,
 
 
 static void
+tny_gtk_folder_list_store_dispose (GObject *object)
+{
+	TnyGtkFolderListStore *me = (TnyGtkFolderListStore*) object;
+
+	me->flags |= TNY_GTK_FOLDER_LIST_STORE_FLAG_DISPOSED;
+
+	(*parent_class->dispose) (object);
+}
+
+static void
 tny_gtk_folder_list_store_finalize (GObject *object)
 {
 	TnyGtkFolderListStore *me = (TnyGtkFolderListStore*) object;
@@ -918,6 +931,7 @@ tny_gtk_folder_list_store_class_init (TnyGtkFolderListStoreClass *class)
 	object_class = (GObjectClass*) class;
 
 	object_class->finalize = tny_gtk_folder_list_store_finalize;
+	object_class->dispose = tny_gtk_folder_list_store_dispose;
 
 	tny_gtk_folder_list_store_signals [ACTIVITY_CHANGED_SIGNAL] =
 		g_signal_new ("activity_changed",
diff --git a/libtinymailui-gtk/tny-gtk-folder-list-store.h b/libtinymailui-gtk/tny-gtk-folder-list-store.h
index af6c63e..d3193a9 100644
--- a/libtinymailui-gtk/tny-gtk-folder-list-store.h
+++ b/libtinymailui-gtk/tny-gtk-folder-list-store.h
@@ -52,11 +52,12 @@ typedef enum
 	TNY_GTK_FOLDER_LIST_STORE_N_COLUMNS
 } TnyGtkFolderListStoreColumn;
 
-typedef enum
+typedef enum 
 {
 	TNY_GTK_FOLDER_LIST_STORE_FLAG_SHOW_PATH = 1<<0,
 	TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH = 1<<2,
 	TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH = 1<<3,
+	TNY_GTK_FOLDER_LIST_STORE_FLAG_DISPOSED = 1<<4,
 } TnyGtkFolderListStoreFlags;
 
 struct _TnyGtkFolderListStore


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]