From 412c2967bb93845e152022aefac70ad93571a288 Mon Sep 17 00:00:00 2001 From: 0 Date: Thu, 20 Sep 2001 21:01:53 +0000 Subject: Register vfolder sources here. 2001-09-20 * mail-tools.c(mail_tool_uri_to_folder): Register vfolder sources here. * folder-browser.c (got_folder): Dont register vfolder sources here. * mail-ops.c (mail_get_folder): Add thread parameter. Fix callers. * mail-vfolder.c (vfolder_setup): Use the 'slow' queue for setting up vfolders. * mail-mt.c (mail_msg_init): Limit the maximum number of threads on the 'new' thread to 10. (mail_msg_init): Create a new queue 'slow' for doing slow operations. svn path=/trunk/; revision=13017 --- mail/ChangeLog | 17 +++++++++++++++++ mail/component-factory.c | 4 ++-- mail/folder-browser.c | 3 +-- mail/mail-folder-cache.c | 2 +- mail/mail-local.c | 2 +- mail/mail-mt.c | 8 ++++++++ mail/mail-mt.h | 1 + mail/mail-ops.c | 6 +++--- mail/mail-ops.h | 3 ++- mail/mail-tools.c | 1 + mail/mail-vfolder.c | 14 ++++++++++++-- 11 files changed, 49 insertions(+), 12 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 57542c79b6..d80996b300 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,20 @@ +2001-09-20 + + * mail-tools.c(mail_tool_uri_to_folder): Register vfolder sources here. + + * folder-browser.c (got_folder): Dont register vfolder sources + here. + + * mail-ops.c (mail_get_folder): Add thread parameter. Fix callers. + + * mail-vfolder.c (vfolder_setup): Use the 'slow' queue for setting + up vfolders. + + * mail-mt.c (mail_msg_init): Limit the maximum number of threads + on the 'new' thread to 10. + (mail_msg_init): Create a new queue 'slow' for doing slow + operations. + 2001-09-20 Iain Holmes * mail-display.c (mail_error_write): Add a
to make the diff --git a/mail/component-factory.c b/mail/component-factory.c index 89f5731a80..6965b004e6 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -207,7 +207,7 @@ create_folder (EvolutionShellComponent *shell_component, CORBA_exception_init (&ev); if (!strcmp (type, "mail")) { - mail_get_folder (physical_uri, create_folder_done, CORBA_Object_duplicate (listener, &ev)); + mail_get_folder(physical_uri, create_folder_done, CORBA_Object_duplicate (listener, &ev), mail_thread_new); } else { GNOME_Evolution_ShellComponentListener_notifyResult ( listener, GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev); @@ -665,7 +665,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) { *standard_folders[i].uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name); - mail_msg_wait (mail_get_folder (*standard_folders[i].uri, got_folder, standard_folders[i].folder)); + mail_msg_wait(mail_get_folder(*standard_folders[i].uri, got_folder, standard_folders[i].folder, mail_thread_new)); } mail_session_enable_interaction (TRUE); diff --git a/mail/folder-browser.c b/mail/folder-browser.c index daa26c49a3..672c8d8724 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -760,7 +760,6 @@ got_folder(char *uri, CamelFolder *folder, void *data) folder_browser_is_drafts (fb) || folder_browser_is_sent (fb) || folder_browser_is_outbox (fb)); - vfolder_register_source (folder); camel_object_hook_event(CAMEL_OBJECT(fb->folder), "folder_changed", folder_changed, fb); @@ -1948,7 +1947,7 @@ folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri) folder_browser->uri = g_strdup (uri); gtk_object_ref (GTK_OBJECT (folder_browser)); - mail_get_folder (folder_browser->uri, got_folder, folder_browser); + mail_get_folder(folder_browser->uri, got_folder, folder_browser, mail_thread_new); return GTK_WIDGET (folder_browser); } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 32c68b75de..3921d4a41b 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -40,7 +40,7 @@ #include "mail-folder-cache.h" #include "mail-ops.h" -#define d(x) x +#define d(x) /* note that many things are effectively serialised by having them run in the main loop thread which they need to do because of corba/gtk calls */ diff --git a/mail/mail-local.c b/mail/mail-local.c index 13d03f75f6..bf5556cfcf 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -852,7 +852,7 @@ static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, co /* this is just so the folder is opened at least once to setup the folder counts etc in the display. Joy eh? The result is discarded. */ - mail_get_folder(uri, NULL, NULL); + mail_get_folder(uri, NULL, NULL, mail_thread_queued_slow); } } diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 634dd91eae..9a2033c2e9 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -244,6 +244,7 @@ static GIOChannel *mail_gui_reply_channel; /* a couple of global threads available */ EThread *mail_thread_queued; /* for operations that can (or should) be queued */ +EThread *mail_thread_queued_slow; /* for operations that can (or should) be queued, but take a long time */ EThread *mail_thread_new; /* for operations that should run in a new thread each time */ static gboolean @@ -344,6 +345,7 @@ mail_msg_received(EThread *e, EMsg *msg, void *data) static void mail_msg_cleanup(void) { + e_thread_destroy(mail_thread_queued_slow); e_thread_destroy(mail_thread_queued); e_thread_destroy(mail_thread_new); @@ -368,10 +370,16 @@ void mail_msg_init(void) e_thread_set_msg_received(mail_thread_queued, mail_msg_received, 0); e_thread_set_reply_port(mail_thread_queued, mail_gui_reply_port); + mail_thread_queued_slow = e_thread_new(E_THREAD_QUEUE); + e_thread_set_msg_destroy(mail_thread_queued_slow, mail_msg_destroy, 0); + e_thread_set_msg_received(mail_thread_queued_slow, mail_msg_received, 0); + e_thread_set_reply_port(mail_thread_queued_slow, mail_gui_reply_port); + mail_thread_new = e_thread_new(E_THREAD_NEW); e_thread_set_msg_destroy(mail_thread_new, mail_msg_destroy, 0); e_thread_set_msg_received(mail_thread_new, mail_msg_received, 0); e_thread_set_reply_port(mail_thread_new, mail_gui_reply_port); + e_thread_set_queue_limit(mail_thread_new, 10); mail_msg_active = g_hash_table_new(NULL, NULL); mail_gui_thread = pthread_self(); diff --git a/mail/mail-mt.h b/mail/mail-mt.h index 6ec2255bc7..8f90c3b0c7 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -77,6 +77,7 @@ extern EMsgPort *mail_gui_reply_port; /* some globally available threads */ extern EThread *mail_thread_queued; /* for operations that can (or should) be queued */ extern EThread *mail_thread_new; /* for operations that should run in a new thread each time */ +extern EThread *mail_thread_queued_slow; /* for operations that can (or should) be queued, but take a long time */ /* The main thread. */ extern pthread_t mail_gui_thread; diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 569160e68e..a29f19a896 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1313,18 +1313,18 @@ static struct _mail_msg_op get_folder_op = { }; int -mail_get_folder (const char *uri, void (*done) (char *uri, CamelFolder *folder, void *data), void *data) +mail_get_folder (const char *uri, void (*done)(char *uri, CamelFolder *folder, void *data), void *data, EThread *thread) { struct _get_folder_msg *m; int id; - m = mail_msg_new (&get_folder_op, NULL, sizeof (*m)); + m = mail_msg_new(&get_folder_op, NULL, sizeof(*m)); m->uri = g_strdup (uri); m->data = data; m->done = done; id = m->msg.seq; - e_thread_put (mail_thread_queued, (EMsg *)m); + e_thread_put(thread, (EMsg *)m); return id; } diff --git a/mail/mail-ops.h b/mail/mail-ops.h index b1f429ba64..bc5a15df9a 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -62,7 +62,8 @@ void mail_get_messages (CamelFolder *folder, GPtrArray *uids, /* same for a folder */ int mail_get_folder (const char *uri, - void (*done) (char *uri, CamelFolder *folder, void *data), void *data); + void (*done) (char *uri, CamelFolder *folder, void *data), void *data, + EThread *thread); /* and for a store */ int mail_get_store (const char *uri, diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 406b5f2c47..830ca4c613 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -366,6 +366,7 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex) folder = NULL; } } else { + vfolder_register_source(folder); mail_note_folder(folder, NULL); } diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 51740bf30f..c5dec4fb64 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -133,6 +133,14 @@ struct _setup_msg { GList *sources_folder; }; +static char * +vfolder_setup_desc(struct _mail_msg *mm, int done) +{ + struct _setup_msg *m = (struct _setup_msg *)mm; + + return g_strdup_printf(_("Setting up vfolder: %s"), m->folder->full_name); +} + static void vfolder_setup_do(struct _mail_msg *mm) { @@ -140,6 +148,8 @@ vfolder_setup_do(struct _mail_msg *mm) GList *l, *list = NULL; CamelFolder *folder; + printf("Setting up vfolder: %s\n", m->folder->full_name); + camel_vee_folder_set_expression((CamelVeeFolder *)m->folder, m->query); l = m->sources_uri; @@ -204,7 +214,7 @@ vfolder_setup_free (struct _mail_msg *mm) } static struct _mail_msg_op vfolder_setup_op = { - NULL, + vfolder_setup_desc, vfolder_setup_do, vfolder_setup_done, vfolder_setup_free, @@ -224,7 +234,7 @@ vfolder_setup(CamelFolder *folder, const char *query, GList *sources_uri, GList m->sources_folder = sources_folder; id = m->msg.seq; - e_thread_put(mail_thread_queued, (EMsg *)m); + e_thread_put(mail_thread_queued_slow, (EMsg *)m); return id; } -- cgit v1.2.3