aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-mt.c
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2001-10-17 03:13:31 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-17 03:13:31 +0800
commit8c85ed61ba64bd548460543dd87445b9a21dbf6a (patch)
tree76d2bc77eb83263b4d5b4122bf47127a1666214b /mail/mail-mt.c
parente1d0f3dc45692a04dbd93c7ef82c24af74e05f25 (diff)
downloadgsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.gz
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.bz2
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.lz
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.xz
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.zst
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.zip
Added an async_event handler to store_info. (mail_note_store): Setup async
* mail-folder-cache.c: Added an async_event handler to store_info. (mail_note_store): Setup async event handler here. (store_finalised): Flush out async events here. (folder_changed): Use async event handler to emit event. (mail_note_folder): Chagned, do most of the work in the calling context, only do the corba stuff in main. (store_folder_subscribed): Use async event, and do more work locally. (store_folder_unsubscribed): Same. (store_folder_deleted): Call store_folder_unsubscribed if we have to do any work. (store_folder_created): Call store_folder_subscribed if we have to do any work. (store_folder_unsubscribed): Ref store while busy. (real_folder_deleted): And unref here. (store_folder_subscribed): Reg store while busy. (real_folder_created): Unref here. (mail_note_folder): Ref folder while busy. (real_note_folder): And unref here. (mail_note_folder): Hook onto folder_deleted event. (folder_deleted): Just mark this folder as no longer available. * mail-session.c (register_timeout): Use mail_call_main instead of proxy_event. (remove_timeout): Same here. * folder-browser.c (folder_changed): use the new mail_async_event stuff. (folder_changed_main): Remove old async event handling stuff. (FOLDER_BROWSER_LOCK/UNLOCK): Removed. (FolderBrowserPrivate): Removed too, sigh. * mail-mt.c (mail_async_event_new, mail_async_event_emit, mail_async_event_destroy): New functions to handle async events. (mail_proxy_event, mail_proxy_event_id): Removed old functions for async events. (do_call): Add suport for MAIL_CALL_p_pp. (mail_msg_free): Use mail_async_event instead of proxy_event. * message-list.c (message_changed): Promote the message_changed to a folder_changed and use main_folder_changed to process it. (main_message_changed): Remove.d (message_list_init): Setup async event handler. (message_list_destroy): Remove async handler. (folder_changed): Use async hanler to emit event in main loop. (message_changed): Same. svn path=/trunk/; revision=13698
Diffstat (limited to 'mail/mail-mt.c')
-rw-r--r--mail/mail-mt.c68
1 files changed, 50 insertions, 18 deletions
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 0892688853..cf64485d85 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -69,6 +69,8 @@ static pthread_cond_t mail_msg_cond = PTHREAD_COND_INITIALIZER;
pthread_t mail_gui_thread;
+MailAsyncEvent *mail_async_event;
+
static void mail_msg_destroy(EThread *e, EMsg *msg, void *data);
void *mail_msg_new(mail_msg_op_t *ops, EMsgPort *reply_port, size_t size)
@@ -184,7 +186,7 @@ void mail_msg_free(void *msg)
g_free(m);
if (activity)
- mail_proxy_event(destroy_objects, NULL, activity, NULL);
+ mail_async_event_emit(mail_async_event, destroy_objects, NULL, activity, NULL);
}
/* hash table of ops->dialogue of active errors */
@@ -473,6 +475,8 @@ void mail_msg_init(void)
mail_msg_active = g_hash_table_new(NULL, NULL);
mail_gui_thread = pthread_self();
+
+ mail_async_event = mail_async_event_new();
}
/* ********************************************************************** */
@@ -764,65 +768,88 @@ mail_user_message (const char *type, const char *prompt, gboolean allow_cancel)
struct _proxy_msg {
struct _mail_msg msg;
+ MailAsyncEvent *ea;
CamelObjectEventHookFunc func;
CamelObject *o;
void *event_data;
void *data;
};
-static int mail_proxy_event_current = -1;
-
static void
-do_proxy_event(struct _mail_msg *mm)
+do_async_event(struct _mail_msg *mm)
{
struct _proxy_msg *m = (struct _proxy_msg *)mm;
- mail_proxy_event_current = mm->seq;
m->func(m->o, m->event_data, m->data);
- mail_proxy_event_current = -1;
+
+ g_mutex_lock(m->ea->lock);
+ m->ea->tasks = g_slist_remove(m->ea->tasks, (void *)mm->seq);
+ g_mutex_unlock(m->ea->lock);
+
}
-struct _mail_msg_op proxy_event_op = {
+struct _mail_msg_op async_event_op = {
NULL,
- do_proxy_event,
+ do_async_event,
NULL,
NULL,
};
-/* returns the current id of the executing proxy event */
-int mail_proxy_event_id(void)
+MailAsyncEvent *mail_async_event_new(void)
{
- return mail_proxy_event_current;
+ MailAsyncEvent *ea;
+
+ ea = g_malloc0(sizeof(*ea));
+ ea->lock = g_mutex_new();
+
+ return ea;
}
-int mail_proxy_event(CamelObjectEventHookFunc func, CamelObject *o, void *event_data, void *data)
+int mail_async_event_emit(MailAsyncEvent *ea, CamelObjectEventHookFunc func, CamelObject *o, void *event_data, void *data)
{
struct _proxy_msg *m;
int id;
int ismain = pthread_self() == mail_gui_thread;
if (ismain) {
- /* save the current id incase we're proxying an event in a proxied event */
- id = mail_proxy_event_current;
- mail_proxy_event_current = -1;
func(o, event_data, data);
- mail_proxy_event_current = id;
/* id of -1 is 'always finished' */
return -1;
} else {
/* we dont have a reply port for this, we dont care when/if it gets executed, just queue it */
- m = mail_msg_new(&proxy_event_op, NULL, sizeof(*m));
+ m = mail_msg_new(&async_event_op, NULL, sizeof(*m));
m->func = func;
m->o = o;
m->event_data = event_data;
m->data = data;
-
+ m->ea = ea;
+
id = m->msg.seq;
+ g_mutex_lock(ea->lock);
+ ea->tasks = g_slist_prepend(ea->tasks, (void *)id);
+ g_mutex_unlock(ea->lock);
e_msgport_put(mail_gui_port, (EMsg *)m);
return id;
}
}
+void mail_async_event_destroy(MailAsyncEvent *ea)
+{
+ int id;
+
+ g_mutex_lock(ea->lock);
+ while (ea->tasks) {
+ id = (int)ea->tasks->data;
+ g_mutex_unlock(ea->lock);
+ mail_msg_wait(id);
+ g_mutex_lock(ea->lock);
+ }
+ g_mutex_unlock(ea->lock);
+
+ g_mutex_free(ea->lock);
+ g_free(ea);
+}
+
/* ********************************************************************** */
struct _call_msg {
@@ -846,6 +873,11 @@ do_call(struct _mail_msg *mm)
p1 = va_arg(ap, void *);
m->ret = m->func(p1);
break;
+ case MAIL_CALL_p_pp:
+ p1 = va_arg(ap, void *);
+ p2 = va_arg(ap, void *);
+ m->ret = m->func(p1, p2);
+ break;
case MAIL_CALL_p_ppp:
p1 = va_arg(ap, void *);
p2 = va_arg(ap, void *);