[PATCH] : just adds gdk_threads_leave()/gdk_threads_enter()



	Hi all,
I'm trying to get more UI responsiveness because I think that we hold the 
gdk lock (which prevent gdk/gtk to handle UI events) too long. Here is a 
first patch that just adds gdk_threads_leave()/gdk_threads_enter() around 
obvious places where it is safe (AFAICS). I think that this could be 
extended all over libbalsa functions that are long enough (or called a 
lot), so that we get more UI responsiveness. There are a couple of places 
where it is more difficult because we grab mailbox locks or mutt lock in 
such a way that it is impossible to safely release the gdk lock, at least 
as the code is now. That could also be corrected but it needs more care.
I'll try to extend that later to more libbalsa sources.
Comments and tests are really welcome ;-) Especially if you could really 
see the effect (ie try to click during checking mails to see if events get 
handled smoother).
Bye
Manu
diff -u balsa/libbalsa/mailbox.c balsa-test/libbalsa/mailbox.c
--- balsa/libbalsa/mailbox.c	Sun Apr 28 07:44:46 2002
+++ balsa-test/libbalsa/mailbox.c	Sun Apr 28 11:24:35 2002
@@ -423,10 +423,12 @@
     int ret;
     g_return_val_if_fail(handle != NULL, -1);
 
+    gdk_threads_leave();
     libbalsa_lock_mutt();
     ret = mx_close_mailbox(handle->context, NULL);
     libbalsa_unlock_mutt();
     g_free(handle);
+    gdk_threads_enter();
     return ret;
 }
 
@@ -564,9 +566,11 @@
 void
 libbalsa_mailbox_sort(LibBalsaMailbox * mailbox, LibBalsaMailboxSort sort)
 {
+    gdk_threads_leave();
     libbalsa_lock_mutt();
     mutt_sort_headers(CLIENT_CONTEXT(mailbox), sort);
     libbalsa_unlock_mutt();
+    gdk_threads_enter();
 }
 
 static void
diff -u balsa/libbalsa/mailbox_imap.c balsa-test/libbalsa/mailbox_imap.c
--- balsa/libbalsa/mailbox_imap.c	Sun Apr 28 07:44:46 2002
+++ balsa-test/libbalsa/mailbox_imap.c	Sun Apr 28 11:17:59 2002
@@ -672,6 +672,7 @@
     LibBalsaMailboxAppendHandle* res = g_new0(LibBalsaMailboxAppendHandle,1);
     server = LIBBALSA_MAILBOX_REMOTE_SERVER(mailbox);
 
+    gdk_threads_leave();
     libbalsa_lock_mutt();
     reset_mutt_passwords(server);
     res->context = mx_open_mailbox(mailbox->url, M_APPEND, NULL);
@@ -687,6 +688,7 @@
 	res = NULL;
     }
     libbalsa_unlock_mutt();
+    gdk_threads_enter();
     return res;
 }
 
diff -u balsa/libbalsa/mailbox_local.c balsa-test/libbalsa/mailbox_local.c
--- balsa/libbalsa/mailbox_local.c	Sun Apr 28 07:44:46 2002
+++ balsa-test/libbalsa/mailbox_local.c	Sun Apr 28 11:16:16 2002
@@ -328,6 +325,7 @@
     LibBalsaMailboxAppendHandle* res;
     g_return_val_if_fail(mailbox, NULL);
 
+    gdk_threads_leave();
     res = g_new0(LibBalsaMailboxAppendHandle,1);
     libbalsa_lock_mutt();
     res->context = mx_open_mailbox(libbalsa_mailbox_local_get_path(mailbox), 
@@ -343,6 +341,7 @@
 	res = NULL;
     }
     libbalsa_unlock_mutt();
+    gdk_threads_enter();
     return res;
 }
 
@@ -355,7 +354,8 @@
     } else {
 	gint i = 0;
 	gint index_hint;
-
+	
+	gdk_threads_leave();
 	LOCK_MAILBOX(mailbox);
 
 	index_hint = CLIENT_CONTEXT(mailbox)->vcount;
@@ -371,11 +371,13 @@
 	    mailbox->new_messages =
 		CLIENT_CONTEXT(mailbox)->msgcount - mailbox->messages;
 	    UNLOCK_MAILBOX(mailbox);
+	    gdk_threads_enter();
 	    libbalsa_mailbox_load_messages(mailbox);
 	    run_filters_on_reception(mailbox);
 
 	} else {
 	    UNLOCK_MAILBOX(mailbox);
+	    gdk_threads_enter();
 	}
     }
 }


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