evolution/evolution-2.8.1-kill-ethread.patch

2020 lines
59 KiB
Diff
Raw Normal View History

--- evolution-2.9.91/mail/mail-send-recv.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-send-recv.c 2007-02-15 16:04:42.000000000 -0500
@@ -819,7 +819,7 @@
m->folders = folders;
m->info = sinfo;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
} else {
receive_done ("", data);
}
--- evolution-2.9.91/mail/mail-component.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-component.c 2007-02-15 16:04:42.000000000 -0500
@@ -965,7 +965,7 @@
if (camel_url_get_param(url, "uid") != NULL) {
char *curi = em_uri_to_camel(uri);
- mail_get_folder(curi, 0, handleuri_got_folder, url, mail_thread_new);
+ mail_get_folder(curi, 0, handleuri_got_folder, url, mail_msg_unordered_push);
g_free(curi);
} else {
g_warning("email uri's must include a uid parameter");
--- evolution-2.9.91/mail/mail-ops.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-ops.c 2007-02-15 16:04:42.000000000 -0500
@@ -221,7 +221,7 @@
camel_filter_driver_remove_rule_by_name (m->driver, "new-mail-notification");
}
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* convenience functions for it */
@@ -426,7 +426,7 @@
if (status)
camel_filter_driver_set_status_func (fm->driver, status, status_data);
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* ********************************************************************** */
@@ -839,7 +839,7 @@
m->driver = camel_session_get_filter_driver (session, type, NULL);
camel_filter_driver_set_folder_func (m->driver, get_folder, get_data);
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* ** APPEND MESSAGE TO FOLDER ******************************************** */
@@ -921,7 +921,7 @@
m->done = done;
m->data = data;
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* ** TRANSFER MESSAGES **************************************************** */
@@ -1036,7 +1036,7 @@
m->done = done;
m->data = data;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ** SCAN SUBFOLDERS ***************************************************** */
@@ -1124,7 +1124,7 @@
m->data = data;
id = m->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
@@ -1250,7 +1250,7 @@
int
mail_get_folder (const char *uri, guint32 flags,
void (*done)(char *uri, CamelFolder *folder, void *data),
- void *data, EThread *thread)
+ void *data, MailMsgDispatchFunc dispatch)
{
struct _get_folder_msg *m;
int id;
@@ -1262,7 +1262,7 @@
m->done = done;
id = m->msg.seq;
- e_thread_put(thread, (EMsg *)m);
+ dispatch ((mail_msg_t *) m);
return id;
}
@@ -1340,7 +1340,7 @@
m->done = done;
id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
@@ -1437,7 +1437,7 @@
m->data = data;
m->done = done;
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* ** SYNC FOLDER ********************************************************* */
@@ -1498,7 +1498,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ** SYNC STORE ********************************************************* */
@@ -1568,7 +1568,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ******************************************************************************** */
@@ -1604,7 +1604,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ******************************************************************************** */
@@ -1640,7 +1640,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ******************************************************************************** */
@@ -1723,7 +1723,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ** GET MESSAGE(s) ***************************************************** */
@@ -1783,7 +1783,7 @@
void
mail_get_message(CamelFolder *folder, const char *uid, void (*done) (CamelFolder *folder, const char *uid,
CamelMimeMessage *msg, void *data),
- void *data, EThread *thread)
+ void *data, MailMsgDispatchFunc dispatch)
{
struct _get_message_msg *m;
@@ -1795,7 +1795,7 @@
m->done = done;
m->cancel = camel_operation_new(NULL, NULL);
- e_thread_put(thread, (EMsg *)m);
+ dispatch ((mail_msg_t *) m);
}
typedef void (*get_done)(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data, CamelException *);
@@ -1821,7 +1821,7 @@
mail_get_message; it adds an exception argument to the callback */
void
mail_get_messagex(CamelFolder *folder, const char *uid, void (*done) (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data, CamelException *),
- void *data, EThread *thread)
+ void *data, MailMsgDispatchFunc dispatch)
{
struct _get_message_msg *m;
@@ -1833,7 +1833,7 @@
m->done = done;
m->cancel = camel_operation_new(NULL, NULL);
- e_thread_put(thread, (EMsg *)m);
+ dispatch ((mail_msg_t *) m);
}
/* ********************************************************************** */
@@ -1920,7 +1920,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
/* ** SAVE MESSAGES ******************************************************* */
@@ -2063,7 +2063,7 @@
m->done = done;
id = m->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
@@ -2156,7 +2156,7 @@
m->readonly = readonly;
id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
@@ -2240,7 +2240,7 @@
m->data = data;
m->done = done;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
/* ** GO OFFLINE ***************************************************** */
@@ -2345,7 +2345,7 @@
m->done = done;
id = m->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
@@ -2433,7 +2433,7 @@
m->data = data;
id = m->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/em-folder-utils.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/em-folder-utils.c 2007-02-15 16:04:42.000000000 -0500
@@ -260,7 +260,7 @@
m->delete = delete;
seq = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return seq;
}
@@ -652,7 +652,7 @@
g_free (namebuf);
id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/importers/elm-importer.c.kill-ethread 2007-01-03 10:27:16.000000000 -0500
+++ evolution-2.9.91/mail/importers/elm-importer.c 2007-02-15 16:04:42.000000000 -0500
@@ -312,7 +312,7 @@
id = m->msg.seq;
- e_thread_put(mail_thread_queued, (EMsg *)m);
+ mail_msg_fast_ordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/importers/mail-importer.c.kill-ethread 2007-01-03 10:27:16.000000000 -0500
+++ evolution-2.9.91/mail/importers/mail-importer.c 2007-02-15 16:04:42.000000000 -0500
@@ -329,7 +329,7 @@
}
id = m->msg.seq;
- e_thread_put(mail_thread_queued, (EMsg *)m);
+ mail_msg_fast_ordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/importers/pine-importer.c.kill-ethread 2007-01-03 10:27:16.000000000 -0500
+++ evolution-2.9.91/mail/importers/pine-importer.c 2007-02-15 16:04:42.000000000 -0500
@@ -350,7 +350,7 @@
id = m->msg.seq;
- e_thread_put(mail_thread_queued, (EMsg *)m);
+ mail_msg_fast_ordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/mail-vfolder.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-vfolder.c 2007-02-15 16:04:42.000000000 -0500
@@ -188,7 +188,7 @@
m->sources_folder = sources_folder;
id = m->msg.seq;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
return id;
}
@@ -323,7 +323,7 @@
m->remove = remove;
id = m->msg.seq;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
return id;
}
@@ -447,7 +447,7 @@
return;
}
- g_assert(pthread_equal(pthread_self(), mail_gui_thread));
+ g_assert(mail_in_main_thread());
is_ignore = uri_is_ignore(store, curi);
@@ -540,7 +540,7 @@
d(printf ("Deleting uri to check: %s\n", uri));
- g_assert (pthread_equal(pthread_self(), mail_gui_thread));
+ g_assert (mail_in_main_thread());
changed = g_string_new ("");
@@ -615,7 +615,7 @@
if (context == NULL || uri_is_spethal(store, cfrom) || uri_is_spethal(store, cto))
return;
- g_assert(pthread_equal(pthread_self(), mail_gui_thread));
+ g_assert(mail_in_main_thread());
from = em_uri_from_camel(cfrom);
to = em_uri_from_camel(cto);
--- evolution-2.9.91/mail/em-format-html.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/em-format-html.c 2007-02-15 16:04:42.000000000 -0500
@@ -1374,7 +1374,7 @@
}
efh->priv->format_id = m->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
efh->priv->format_timeout_id = 0;
--- evolution-2.9.91/mail/em-folder-properties.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/em-folder-properties.c 2007-02-15 16:04:42.000000000 -0500
@@ -379,7 +379,7 @@
}
if (folder == NULL)
- mail_get_folder(uri, 0, emfp_dialog_got_folder, NULL, mail_thread_new);
+ mail_get_folder(uri, 0, emfp_dialog_got_folder, NULL, mail_msg_unordered_push);
else
emfp_dialog_got_folder((char *)uri, folder, NULL);
}
--- evolution-2.9.91/mail/em-folder-tree.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/em-folder-tree.c 2007-02-15 16:04:42.000000000 -0500
@@ -966,7 +966,7 @@
tree_drag_data_action(struct _DragDataReceivedAsync *m)
{
m->move = m->action == GDK_ACTION_MOVE;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
static void
@@ -1891,7 +1891,7 @@
m->top = full_name;
m->flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
static gboolean
--- evolution-2.9.91/mail/em-folder-browser.c.kill-ethread 2007-02-12 05:37:31.000000000 -0500
+++ evolution-2.9.91/mail/em-folder-browser.c 2007-02-15 16:04:42.000000000 -0500
@@ -948,7 +948,7 @@
m->sources_folder = sources_folder;
id = m->msg.seq;
- e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/message-list.c.kill-ethread 2007-01-18 07:31:51.000000000 -0500
+++ evolution-2.9.91/mail/message-list.c 2007-02-15 16:04:42.000000000 -0500
@@ -1888,7 +1888,7 @@
ml_drop_action(struct _drop_msg *m)
{
m->move = m->action == GDK_ACTION_MOVE;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
}
static void
@@ -3922,7 +3922,7 @@
m->ml->regen = g_list_prepend(m->ml->regen, m);
/* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */
- e_thread_put (mail_thread_queued, (EMsg *)m);
+ mail_msg_fast_ordered_push ((mail_msg_t *) m);
m->ml->regen_timeout_msg = NULL;
m->ml->regen_timeout_id = 0;
--- evolution-2.9.91/mail/em-format-html-print.c.kill-ethread 2007-02-12 01:58:01.000000000 -0500
+++ evolution-2.9.91/mail/em-format-html-print.c 2007-02-15 16:04:42.000000000 -0500
@@ -262,7 +262,7 @@
g_object_ref(source);
g_object_ref(efhp);
- mail_get_message(folder, uid, emfhp_got_message, efhp, mail_thread_new);
+ mail_get_message(folder, uid, emfhp_got_message, efhp, mail_msg_unordered_push);
return 0; /* damn async ... */
}
--- evolution-2.9.91/mail/em-sync-stream.c.kill-ethread 2007-02-09 15:16:33.000000000 -0500
+++ evolution-2.9.91/mail/em-sync-stream.c 2007-02-15 16:04:42.000000000 -0500
@@ -268,7 +268,7 @@
if (emss->cancel)
return -1;
- if (pthread_equal(pthread_self(), mail_gui_thread)) {
+ if (mail_in_main_thread ()) {
EMSS_CLASS(emss)->sync_write(stream, buffer, n);
#ifdef LOG_STREAM
if (p->logfd)
@@ -298,7 +298,7 @@
if (emss->cancel)
return -1;
- if (pthread_equal(pthread_self(), mail_gui_thread))
+ if (mail_in_main_thread ())
return ((EMSyncStreamClass *)(((CamelObject *)emss)->klass))->sync_flush(stream);
else
sync_op(emss, EMSS_FLUSH, NULL, 0);
@@ -316,7 +316,7 @@
d(printf("%p: closing stream\n", stream));
- if (pthread_equal(pthread_self(), mail_gui_thread)) {
+ if (mail_in_main_thread ()) {
#ifdef LOG_STREAM
if (emss->priv->logfd) {
fclose(emss->priv->logfd);
--- evolution-2.9.91/mail/em-subscribe-editor.c.kill-ethread 2007-01-08 11:35:48.000000000 -0500
+++ evolution-2.9.91/mail/em-subscribe-editor.c 2007-02-15 16:04:42.000000000 -0500
@@ -229,7 +229,7 @@
next = (struct _zsubscribe_msg *)e_dlist_remhead(&m->sub->subscribe);
if (next) {
next->sub->subscribe_id = next->msg.seq;
- e_thread_put(mail_thread_new, (EMsg *)next);
+ mail_msg_unordered_push ((mail_msg_t *) next);
} else {
/* should it go off the model instead? */
sub_selection_changed(gtk_tree_view_get_selection(m->sub->tree), m->sub);
@@ -270,7 +270,7 @@
if (sub->subscribe_id == -1) {
sub->subscribe_id = id;
d(printf("running subscribe folder '%s'\n", spath));
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
} else {
d(printf("queueing subscribe folder '%s'\n", spath));
e_dlist_addtail(&sub->subscribe, (EDListNode *)m);
@@ -443,7 +443,7 @@
id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *)m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/mail/mail-mt.h.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-mt.h 2007-02-15 16:04:42.000000000 -0500
@@ -33,6 +33,7 @@
EMsg msg; /* parent type */
struct _mail_msg_op *ops; /* operation functions */
unsigned int seq; /* seq number for synchronisation */
+ gint priority; /* priority (default = 0) */
CamelOperation *cancel; /* a cancellation/status handle */
CamelException ex; /* an initialised camel exception, upto the caller to use this */
struct _mail_msg_priv *priv; /* private for internal use */
@@ -51,6 +52,8 @@
void mail_msg_init(void);
void mail_msg_cleanup (void);
+gboolean mail_in_main_thread (void);
+
/* allocate a new message */
void *mail_msg_new(mail_msg_op_t *ops, EMsgPort *reply_port, size_t size);
void mail_msg_free(void *msg);
@@ -60,6 +63,14 @@
void mail_msg_wait_all(void);
int mail_msg_active(unsigned int msgid);
+/* dispatch a message */
+void mail_msg_main_loop_push (mail_msg_t *msg);
+void mail_msg_unordered_push (mail_msg_t *msg);
+void mail_msg_fast_ordered_push (mail_msg_t *msg);
+void mail_msg_slow_ordered_push (mail_msg_t *msg);
+
+typedef void (*MailMsgDispatchFunc) (mail_msg_t *msg);
+
/* To implement the stop button */
void *mail_cancel_hook_add(GDestroyNotify func, void *data);
void mail_cancel_hook_remove(void *handle);
@@ -112,24 +123,6 @@
void mail_enable_stop(void);
void mail_disable_stop(void);
-/* a message port that receives messages in the gui thread, used for sending port */
-extern EMsgPort *mail_gui_port;
-/* a message port that receives messages in the gui thread, used for the reply port */
-extern EMsgPort *mail_gui_reply_port;
-
-/* some globally available threads */
-#ifndef G_OS_WIN32
-extern EThread *mail_thread_queued; /* for operations that can (or should) be queued */
-#else
-EThread *mail_win32_get_mail_thread_queued (void);
-#define mail_thread_queued mail_win32_get_mail_thread_queued ()
-#endif
-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;
-
/* A generic proxy event for anything that can be proxied during the life of the mailer (almost nothing) */
/* Note that almost all objects care about the lifecycle of their events, so this cannot be used */
extern MailAsyncEvent *mail_async_event;
--- evolution-2.9.91/mail/mail-ops.h.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-ops.h 2007-02-15 16:04:42.000000000 -0500
@@ -30,6 +30,8 @@
#pragma }
#endif /* __cplusplus */
+#include "mail-mt.h"
+
#include "camel/camel-store.h"
#include "camel/camel-folder.h"
#include "camel/camel-filter-driver.h"
@@ -55,12 +57,12 @@
void mail_get_message (CamelFolder *folder, const char *uid,
void (*done) (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data),
void *data,
- EThread *thread);
+ MailMsgDispatchFunc dispatch);
void
mail_get_messagex(CamelFolder *folder, const char *uid,
void (*done) (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data, CamelException *),
- void *data, EThread *thread);
+ void *data, MailMsgDispatchFunc dispatch);
/* get several messages */
void mail_get_messages (CamelFolder *folder, GPtrArray *uids,
@@ -70,7 +72,7 @@
/* same for a folder */
int mail_get_folder (const char *uri, guint32 flags,
void (*done) (char *uri, CamelFolder *folder, void *data), void *data,
- EThread *thread);
+ MailMsgDispatchFunc dispatch);
/* and for a store */
int mail_get_store (const char *uri, CamelOperation *op,
--- evolution-2.9.91/mail/em-composer-utils.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/em-composer-utils.c 2007-02-15 16:04:42.000000000 -0500
@@ -534,7 +534,7 @@
strcmp (account->drafts_folder_uri, default_drafts_folder_uri) != 0) {
int id;
- id = mail_get_folder (account->drafts_folder_uri, 0, save_draft_folder, &folder, mail_thread_new);
+ id = mail_get_folder (account->drafts_folder_uri, 0, save_draft_folder, &folder, mail_msg_unordered_push);
mail_msg_wait (id);
if (!folder || !account->enabled) {
@@ -1085,7 +1085,7 @@
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uid != NULL);
- mail_get_message (folder, uid, redirect_msg, NULL, mail_thread_new);
+ mail_get_message (folder, uid, redirect_msg, NULL, mail_msg_unordered_push);
}
static void
@@ -1116,7 +1116,7 @@
}
if (msg == NULL) {
- mail_get_messagex(folder, uid, emu_handle_receipt_message, NULL, mail_thread_new);
+ mail_get_messagex(folder, uid, emu_handle_receipt_message, NULL, mail_msg_unordered_push);
camel_message_info_free(info);
return;
}
@@ -1916,7 +1916,7 @@
rd->source = source;
if (rd->source)
g_object_ref(rd->source);
- mail_get_message(folder, uid, reply_to_message, rd, mail_thread_new);
+ mail_get_message(folder, uid, reply_to_message, rd, mail_msg_unordered_push);
return;
}
@@ -2088,5 +2088,5 @@
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uid != NULL);
- mail_get_message (folder, uid, post_reply_to_message, NULL, mail_thread_new);
+ mail_get_message (folder, uid, post_reply_to_message, NULL, mail_msg_unordered_push);
}
--- evolution-2.9.91/mail/mail-folder-cache.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-folder-cache.c 2007-02-15 16:04:42.000000000 -0500
@@ -907,7 +907,7 @@
m->store = store;
camel_object_ref (store);
- e_thread_put (mail_thread_queued_slow, (EMsg *) m);
+ mail_msg_slow_ordered_push ((mail_msg_t *) m);
}
static gboolean
@@ -952,7 +952,7 @@
int hook = 0;
g_assert(CAMEL_IS_STORE(store));
- g_assert(pthread_equal(pthread_self(), mail_gui_thread));
+ g_assert(mail_in_main_thread());
LOCK(info_lock);
--- evolution-2.9.91/mail/em-folder-view.c.kill-ethread 2007-02-12 01:58:01.000000000 -0500
+++ evolution-2.9.91/mail/em-folder-view.c 2007-02-15 16:04:42.000000000 -0500
@@ -693,7 +693,7 @@
static void
emfv_set_folder_uri(EMFolderView *emfv, const char *uri)
{
- mail_get_folder(uri, 0, emfv_got_folder, emfv, mail_thread_queued);
+ mail_get_folder(uri, 0, emfv_got_folder, emfv, mail_msg_fast_ordered_push);
}
static void
@@ -1611,7 +1611,7 @@
data->type = type;
data->source = source;
- mail_get_message (folder, uid, filter_type_got_message, data, mail_thread_new);
+ mail_get_message (folder, uid, filter_type_got_message, data, mail_msg_unordered_push);
}
static void
@@ -1709,7 +1709,7 @@
data->type = type;
data->uri = g_strdup (uri);
- mail_get_message (folder, uid, vfolder_type_got_message, data, mail_thread_new);
+ mail_get_message (folder, uid, vfolder_type_got_message, data, mail_msg_unordered_push);
}
static void
@@ -2369,7 +2369,7 @@
g_object_ref (emfv);
/* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */
e_profile_event_emit("goto.load", emfv->displayed_uid, 0);
- mail_get_messagex(emfv->folder, emfv->displayed_uid, emfv_list_done_message_selected, emfv, mail_thread_queued);
+ mail_get_messagex(emfv->folder, emfv->displayed_uid, emfv_list_done_message_selected, emfv, mail_msg_fast_ordered_push);
} else {
e_profile_event_emit("goto.empty", "", 0);
g_free(emfv->priv->selected_uid);
--- evolution-2.9.91/mail/mail-session.c.kill-ethread 2007-02-15 16:04:42.000000000 -0500
+++ evolution-2.9.91/mail/mail-session.c 2007-02-15 16:04:42.000000000 -0500
@@ -374,7 +374,7 @@
if (cancel)
user_message_reply = e_msgport_new ();
m = mail_msg_new (&user_message_op, user_message_reply, sizeof (*m));
- m->ismain = pthread_equal(pthread_self(), mail_gui_thread);
+ m->ismain = mail_in_main_thread();
m->type = type;
m->prompt = g_strdup(prompt);
m->allow_cancel = cancel;
@@ -382,9 +382,7 @@
if (m->ismain)
do_user_message((struct _mail_msg *)m);
else {
- extern EMsgPort *mail_gui_port2;
-
- e_msgport_put(mail_gui_port2, (EMsg *)m);
+ mail_msg_main_loop_push((mail_msg_t *) m);
}
if (cancel) {
--- evolution-2.9.91/mail/mail-mt.c.kill-ethread 2007-01-03 10:27:18.000000000 -0500
+++ evolution-2.9.91/mail/mail-mt.c 2007-02-15 16:28:12.000000000 -0500
@@ -82,12 +82,8 @@
static pthread_mutex_t mail_msg_lock = PTHREAD_MUTEX_INITIALIZER;
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)
{
struct _mail_msg *msg;
@@ -112,7 +108,6 @@
fprintf(log, "Logging async operations\n");
if (log_locks) {
- fprintf(log, "Logging lock operations, mail_gui_thread = %" G_GINT64_MODIFIER "x\n\n", e_util_pthread_id(mail_gui_thread));
fprintf(log, "%" G_GINT64_MODIFIER "x: lock mail_msg_lock\n", e_util_pthread_id(pthread_self()));
}
} else {
@@ -308,9 +303,8 @@
void mail_msg_wait(unsigned int msgid)
{
struct _mail_msg *m;
- int ismain = pthread_equal(pthread_self(), mail_gui_thread);
- if (ismain) {
+ if (mail_in_main_thread ()) {
MAIL_MT_LOCK(mail_msg_lock);
m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
while (m) {
@@ -347,9 +341,7 @@
void mail_msg_wait_all(void)
{
- int ismain = pthread_equal(pthread_self(), mail_gui_thread);
-
- if (ismain) {
+ if (mail_in_main_thread ()) {
MAIL_MT_LOCK(mail_msg_lock);
while (g_hash_table_size(mail_msg_active_table) > 0) {
MAIL_MT_UNLOCK(mail_msg_lock);
@@ -420,241 +412,193 @@
MAIL_MT_UNLOCK(mail_msg_lock);
}
-EMsgPort *mail_gui_port;
-static GIOChannel *mail_gui_channel;
-static guint mail_gui_watch;
-
-/* TODO: Merge these, gui_port2 doesn't do any mail_msg processing on the request (replies, forwards, frees) */
-EMsgPort *mail_gui_port2;
-static GIOChannel *mail_gui_channel2;
-static guint mail_gui_watch2;
-
-EMsgPort *mail_gui_reply_port;
-static GIOChannel *mail_gui_reply_channel;
-
-/* a couple of global threads available */
-#ifdef G_OS_WIN32
-#undef mail_thread_queued
-static
-#endif
-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 */
-
-#ifdef G_OS_WIN32
-EThread *
-mail_win32_get_mail_thread_queued (void)
+#define PERIODIC_RATE_HZ 10
+static guint periodic_source_id = 0;
+static GAsyncQueue *main_loop_queue = NULL;
+static GAsyncQueue *msg_reply_queue = NULL;
+static GThread *main_thread = NULL;
+
+static void
+periodic_cleanup (void)
{
- return mail_thread_queued;
+ periodic_source_id = 0;
+
+ g_assert (main_loop_queue != NULL);
+ g_async_queue_unref (main_loop_queue);
+ main_loop_queue = NULL;
+
+ g_assert (msg_reply_queue != NULL);
+ g_async_queue_unref (msg_reply_queue);
+ msg_reply_queue = NULL;
}
-#endif
static gboolean
-mail_msgport_replied(GIOChannel *source, GIOCondition cond, void *d)
+periodic_processing (void)
{
- EMsgPort *port = (EMsgPort *)d;
- mail_msg_t *m;
+ mail_msg_t *msg;
- while (( m = (mail_msg_t *)e_msgport_get(port))) {
+ g_assert (main_loop_queue != NULL);
+ g_assert (msg_reply_queue != NULL);
-#ifdef MALLOC_CHECK
- checkmem(m);
- checkmem(m->cancel);
- checkmem(m->priv);
-#endif
-
-#ifdef LOG_OPS
- if (log_ops)
- fprintf(log, "%p: Replied to GUI thread (exception `%s'\n", m,
- camel_exception_get_description(&m->ex)?camel_exception_get_description(&m->ex):"None");
-#endif
+ /* check the main loop queue */
+ while ((msg = g_async_queue_try_pop (main_loop_queue)) != NULL) {
+
+ /* If the message has a reply_port, it must also have a
+ * receive_msg() callback. The receive_msg() callback is
+ * responsible for issuing the reply, and the recipient of
+ * the reply is responsible for freeing the message. */
+ if (msg->msg.reply_port != NULL) {
+ g_assert (msg->ops->receive_msg != NULL);
+ msg->ops->receive_msg (msg);
+ } else {
+ if (msg->ops->receive_msg != NULL)
+ msg->ops->receive_msg (msg);
+ if (msg->ops->reply_msg != NULL)
+ msg->ops->reply_msg (msg);
+ mail_msg_free (msg);
+ }
+ }
- if (m->ops->reply_msg)
- m->ops->reply_msg(m);
- mail_msg_check_error(m);
- mail_msg_free(m);
+ /* check the reply queue */
+ while ((msg = g_async_queue_try_pop (msg_reply_queue)) != NULL) {
+ if (msg->ops->reply_msg != NULL)
+ msg->ops->reply_msg (msg);
+ mail_msg_check_error (msg);
+ mail_msg_free (msg);
}
return TRUE;
}
-static gboolean
-mail_msgport_received(GIOChannel *source, GIOCondition cond, void *d)
+static void
+mail_msg_proxy (mail_msg_t *msg)
{
- EMsgPort *port = (EMsgPort *)d;
- mail_msg_t *m;
+ if (msg->ops->describe_msg != NULL) {
+ gchar *text = msg->ops->describe_msg (msg, FALSE);
+ camel_operation_register (msg->cancel);
+ camel_operation_start (msg->cancel, "%s", text);
+ g_free (text);
+ }
+
+ if (msg->ops->receive_msg != NULL) {
+ mail_enable_stop ();
+ msg->ops->receive_msg (msg);
+ mail_disable_stop ();
+ }
+
+ if (msg->ops->describe_msg != NULL) {
+ camel_operation_end (msg->cancel);
+ camel_operation_unregister (msg->cancel);
+ MAIL_MT_LOCK (mail_msg_lock);
+ camel_operation_unref (msg->cancel);
+ msg->cancel = NULL;
+ MAIL_MT_UNLOCK (mail_msg_lock);
+ }
- while (( m = (mail_msg_t *)e_msgport_get(port))) {
-#ifdef MALLOC_CHECK
- checkmem(m);
- checkmem(m->cancel);
- checkmem(m->priv);
-#endif
+ g_async_queue_push (msg_reply_queue, msg);
+}
-#ifdef LOG_OPS
- if (log_ops)
- fprintf(log, "%p: Received at GUI thread\n", m);
-#endif
+void
+mail_msg_cleanup (void)
+{
+ GSource *source;
- if (m->ops->receive_msg)
- m->ops->receive_msg(m);
- if (m->msg.reply_port)
- e_msgport_reply((EMsg *)m);
- else {
- if (m->ops->reply_msg)
- m->ops->reply_msg(m);
- mail_msg_free(m);
- }
- }
+ mail_msg_wait_all();
- return TRUE;
+ /* stop periodic processing */
+ source = g_main_context_find_source_by_id (
+ g_main_context_default (), periodic_source_id);
+ g_assert (source != NULL);
+ g_source_destroy (source);
}
-/* Test code, lighterwight, more configurable calls */
-static gboolean
-mail_msgport_received2(GIOChannel *source, GIOCondition cond, void *d)
+void
+mail_msg_init (void)
{
- EMsgPort *port = (EMsgPort *)d;
- mail_msg_t *m;
+ main_loop_queue = g_async_queue_new ();
+ msg_reply_queue = g_async_queue_new ();
- while (( m = (mail_msg_t *)e_msgport_get(port))) {
-#ifdef LOG_OPS
- if (log_ops)
- fprintf(log, "%p: Received at GUI2 thread\n", m);
-#endif
+ /* start periodic processing */
+ periodic_source_id = g_timeout_add_full (
+ G_PRIORITY_DEFAULT,
+ 1000 / PERIODIC_RATE_HZ,
+ (GSourceFunc) periodic_processing, NULL,
+ (GDestroyNotify) periodic_cleanup);
- if (m->ops->receive_msg)
- m->ops->receive_msg(m);
- else
- mail_msg_free(m);
- }
+ mail_msg_active_table = g_hash_table_new (NULL, NULL);
+ main_thread = g_thread_self ();
- return TRUE;
+ mail_async_event = mail_async_event_new ();
}
-
-static void
-mail_msg_destroy(EThread *e, EMsg *msg, void *data)
+static gint
+mail_msg_compare (const mail_msg_t *msg1, const mail_msg_t *msg2)
{
- mail_msg_t *m = (mail_msg_t *)msg;
+ gint priority1 = msg1->priority;
+ gint priority2 = msg2->priority;
-#ifdef MALLOC_CHECK
- checkmem(m);
- checkmem(m->cancel);
- checkmem(m->priv);
-#endif
+ if (priority1 == priority2)
+ return 0;
- mail_msg_free(m);
+ return (priority1 < priority2) ? 1 : -1;
}
-static void
-mail_msg_received(EThread *e, EMsg *msg, void *data)
+static gpointer
+create_thread_pool (gpointer data)
{
- mail_msg_t *m = (mail_msg_t *)msg;
+ GThreadPool *thread_pool;
+ gint max_threads = GPOINTER_TO_INT (data);
-#ifdef MALLOC_CHECK
- checkmem(m);
- checkmem(m->cancel);
- checkmem(m->priv);
-#endif
+ /* once created, run forever */
+ thread_pool = g_thread_pool_new (
+ (GFunc) mail_msg_proxy, NULL, max_threads, FALSE, NULL);
+ g_thread_pool_set_sort_function (
+ thread_pool, (GCompareDataFunc) mail_msg_compare, NULL);
- if (m->ops->describe_msg) {
- char *text = m->ops->describe_msg(m, FALSE);
+ return thread_pool;
+}
-#ifdef LOG_OPS
- if (log_ops)
- fprintf(log, "%p: Received at thread %" G_GINT64_MODIFIER "x: '%s'\n", m, e_util_pthread_id(pthread_self()), text);
-#endif
+void
+mail_msg_main_loop_push (mail_msg_t *msg)
+{
+ g_async_queue_push_sorted (main_loop_queue, msg,
+ (GCompareDataFunc) mail_msg_compare, NULL);
+}
- d(printf("message received at thread\n"));
- camel_operation_register(m->cancel);
- camel_operation_start(m->cancel, "%s", text);
- g_free(text);
- }
-#ifdef LOG_OPS
- else
- if (log_ops)
- fprintf(log, "%p: Received at thread %" G_GINT64_MODIFIER "x\n", m, e_util_pthread_id(pthread_self()));
-#endif
+void
+mail_msg_unordered_push (mail_msg_t *msg)
+{
+ static GOnce once = G_ONCE_INIT;
- if (m->ops->receive_msg) {
- mail_enable_stop();
- m->ops->receive_msg(m);
- mail_disable_stop();
- }
+ g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (10));
- if (m->ops->describe_msg) {
- camel_operation_end(m->cancel);
- camel_operation_unregister(m->cancel);
- MAIL_MT_LOCK(mail_msg_lock);
- camel_operation_unref(m->cancel);
- m->cancel = NULL;
- MAIL_MT_UNLOCK(mail_msg_lock);
- }
+ g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
}
-void mail_msg_cleanup(void)
+void
+mail_msg_fast_ordered_push (mail_msg_t *msg)
{
- mail_msg_wait_all();
-
- e_thread_destroy(mail_thread_queued_slow);
- e_thread_destroy(mail_thread_queued);
- e_thread_destroy(mail_thread_new);
+ static GOnce once = G_ONCE_INIT;
- g_io_channel_unref(mail_gui_channel);
- g_io_channel_unref(mail_gui_reply_channel);
+ g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (1));
- e_msgport_destroy(mail_gui_port);
- e_msgport_destroy(mail_gui_reply_port);
+ g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
}
-static guint
-em_channel_setup(EMsgPort **port, GIOChannel **channel, GIOFunc func)
+void
+mail_msg_slow_ordered_push (mail_msg_t *msg)
{
- GSource *source;
- guint id;
+ static GOnce once = G_ONCE_INIT;
- *port = e_msgport_new();
-#ifndef G_OS_WIN32
- *channel = g_io_channel_unix_new(e_msgport_fd(*port));
-#else
- *channel = g_io_channel_win32_new_socket(e_msgport_fd(*port));
-#endif
- source = g_io_create_watch(*channel, G_IO_IN);
- g_source_set_callback(source, (GSourceFunc)func, *port, NULL);
- g_source_set_can_recurse(source, FALSE);
- id = g_source_attach(source, NULL);
- g_source_unref(source);
+ g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (1));
- return id;
+ g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
}
-void mail_msg_init(void)
+gboolean
+mail_in_main_thread (void)
{
- em_channel_setup(&mail_gui_reply_port, &mail_gui_reply_channel, mail_msgport_replied);
- mail_gui_watch = em_channel_setup(&mail_gui_port, &mail_gui_channel, mail_msgport_received);
- mail_gui_watch2 = em_channel_setup(&mail_gui_port2, &mail_gui_channel2, mail_msgport_received2);
-
- mail_thread_queued = e_thread_new(E_THREAD_QUEUE);
- e_thread_set_msg_destroy(mail_thread_queued, mail_msg_destroy, 0);
- 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_table = g_hash_table_new(NULL, NULL);
- mail_gui_thread = pthread_self();
-
- mail_async_event = mail_async_event_new();
+ return (g_thread_self () == main_thread);
}
/* ********************************************************************** */
@@ -723,7 +667,6 @@
{
struct _proxy_msg *m;
int id;
- int ismain = pthread_equal(pthread_self(), mail_gui_thread);
/* we dont have a reply port for this, we dont care when/if it gets executed, just queue it */
m = mail_msg_new(&async_event_op, NULL, sizeof(*m));
@@ -743,12 +686,12 @@
/* We use an idle function instead of our own message port only because the
gui message ports's notification buffer might overflow and deadlock us */
if (type == MAIL_ASYNC_GUI) {
- if (ismain)
+ if (mail_in_main_thread ())
g_idle_add(idle_async_event, m);
else
- e_msgport_put(mail_gui_port, (EMsg *)m);
+ mail_msg_main_loop_push((mail_msg_t *) m);
} else
- e_thread_put(mail_thread_queued, (EMsg *)m);
+ mail_msg_fast_ordered_push ((mail_msg_t *) m);
return id;
}
@@ -842,6 +785,9 @@
m->ret = m->func(p1, p2, i1, p3, p4, p5);
break;
}
+
+ if (mm->msg.reply_port != NULL)
+ e_msgport_reply ((EMsg *) mm);
}
static struct _mail_msg_op mail_call_op = {
@@ -857,11 +803,10 @@
void *ret;
va_list ap;
EMsgPort *reply = NULL;
- int ismain = pthread_equal(pthread_self(), mail_gui_thread);
va_start(ap, func);
- if (!ismain)
+ if (!mail_in_main_thread ())
reply = e_msgport_new();
m = mail_msg_new(&mail_call_op, reply, sizeof(*m));
@@ -869,8 +814,8 @@
m->func = func;
G_VA_COPY(m->ap, ap);
- if (!ismain) {
- e_msgport_put(mail_gui_port, (EMsg *)m);
+ if (reply != NULL) {
+ mail_msg_main_loop_push((mail_msg_t *) m);
e_msgport_wait(reply);
e_msgport_destroy(reply);
} else {
@@ -909,7 +854,7 @@
busy_state++;
if (busy_state == 1) {
m = mail_msg_new(&set_busy_op, NULL, sizeof(*m));
- e_msgport_put(mail_gui_port, (EMsg *)m);
+ mail_msg_main_loop_push((mail_msg_t *) m);
}
MAIL_MT_UNLOCK(status_lock);
}
@@ -922,7 +867,7 @@
busy_state--;
if (busy_state == 0) {
m = mail_msg_new(&set_busy_op, NULL, sizeof(*m));
- e_msgport_put(mail_gui_port, (EMsg *)m);
+ mail_msg_main_loop_push((mail_msg_t *) m);
}
MAIL_MT_UNLOCK(status_lock);
}
@@ -947,7 +892,7 @@
char *out, *p, *o, c;
int pc;
- g_assert (pthread_equal(mail_gui_thread, pthread_self ()));
+ g_assert (mail_in_main_thread ());
MAIL_MT_LOCK (mail_msg_lock);
@@ -1055,7 +1000,7 @@
}
m->pc = pc;
m->data = data;
- e_msgport_put(mail_gui_port, (EMsg *)m);
+ mail_msg_main_loop_push((mail_msg_t *) m);
}
/* ******************** */
--- evolution-2.9.91/plugins/folder-unsubscribe/folder-unsubscribe.c.kill-ethread 2007-01-03 10:27:06.000000000 -0500
+++ evolution-2.9.91/plugins/folder-unsubscribe/folder-unsubscribe.c 2007-02-15 16:04:42.000000000 -0500
@@ -108,5 +108,5 @@
unsub = mail_msg_new (&unsubscribe_op, NULL, sizeof (struct _folder_unsub_t));
unsub->uri = g_strdup (target->uri);
- e_thread_put (mail_thread_new, (EMsg *) unsub);
+ mail_msg_unordered_push ((mail_msg_t *) unsub);
}
--- evolution-2.9.91/plugins/mark-all-read/mark-all-read.c.kill-ethread 2007-01-03 10:27:08.000000000 -0500
+++ evolution-2.9.91/plugins/mark-all-read/mark-all-read.c 2007-02-15 16:04:42.000000000 -0500
@@ -44,7 +44,7 @@
return;
}
- mail_get_folder(t->uri, 0, mar_got_folder, NULL, mail_thread_new);
+ mail_get_folder(t->uri, 0, mar_got_folder, NULL, mail_msg_unordered_push);
}
static void
--- evolution-2.9.91/plugins/exchange-operations/exchange-folder.c.kill-ethread 2007-01-03 10:27:08.000000000 -0500
+++ evolution-2.9.91/plugins/exchange-operations/exchange-folder.c 2007-02-15 16:04:42.000000000 -0500
@@ -134,7 +134,7 @@
inbox_physical_uri = e_folder_get_physical_uri (inbox);
/* To get the CamelStore/Folder */
- mail_get_folder (inbox_physical_uri, 0, exchange_get_folder, target_uri, mail_thread_new);
+ mail_get_folder (inbox_physical_uri, 0, exchange_get_folder, target_uri, mail_msg_unordered_push);
}
--- evolution-2.9.91/plugins/save-attachments/save-attachments.c.kill-ethread 2007-02-09 15:16:33.000000000 -0500
+++ evolution-2.9.91/plugins/save-attachments/save-attachments.c 2007-02-15 16:04:42.000000000 -0500
@@ -407,5 +407,5 @@
camel_object_ref(data->folder);
data->uid = g_strdup(target->uids->pdata[0]);
- mail_get_message(data->folder, data->uid, save_got_message, data, mail_thread_new);
+ mail_get_message(data->folder, data->uid, save_got_message, data, mail_msg_unordered_push);
}
--- evolution-2.9.91/plugins/mailing-list-actions/mailing-list-actions.c.kill-ethread 2007-01-03 10:27:09.000000000 -0500
+++ evolution-2.9.91/plugins/mailing-list-actions/mailing-list-actions.c 2007-02-15 16:04:42.000000000 -0500
@@ -89,7 +89,7 @@
data->uri = strdup (sel->uri);
mail_get_message (sel->folder, (const char*) g_ptr_array_index (sel->uids, 0),
- emla_list_action_do, data, mail_thread_new);
+ emla_list_action_do, data, mail_msg_unordered_push);
}
void emla_list_action_do (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data)
--- evolution-2.9.91/plugins/groupwise-features/share-folder-common.c.kill-ethread 2007-01-03 10:27:07.000000000 -0500
+++ evolution-2.9.91/plugins/groupwise-features/share-folder-common.c 2007-02-15 16:04:42.000000000 -0500
@@ -239,7 +239,7 @@
m->done = done;
g_free (namebuf);
id = m->msg.seq;
- e_thread_put (mail_thread_new, (EMsg *) m);
+ mail_msg_unordered_push ((mail_msg_t *) m);
return id;
}
--- evolution-2.9.91/calendar/gui/alarm-notify/alarm-notify.h.kill-ethread 2007-01-03 10:27:57.000000000 -0500
+++ evolution-2.9.91/calendar/gui/alarm-notify/alarm-notify.h 2007-02-15 16:04:42.000000000 -0500
@@ -39,19 +39,6 @@
typedef struct _AlarmNotifyPrivate AlarmNotifyPrivate;
-typedef struct _AlarmMsg AlarmMsg;
-typedef struct _AlarmMsgPrivate AlarmMsgPrivate;
-
-struct _AlarmMsg {
- EMsg msg;
-
- void (*receive_msg)(EThread *e, struct _AlarmMsg *msg, void *data); /* message received */
- void *data;
-
- /* Private Usage */
- struct _AlarmMsgPrivate *priv;
-};
-
struct _AlarmNotify {
BonoboObject object;
--- evolution-2.9.91/calendar/gui/alarm-notify/alarm-notify.c.kill-ethread 2007-01-03 10:27:57.000000000 -0500
+++ evolution-2.9.91/calendar/gui/alarm-notify/alarm-notify.c 2007-02-15 16:04:42.000000000 -0500
@@ -45,10 +45,6 @@
GMutex *mutex;
};
-EThread *alarm_operation_thread; /* for operations that can (or should) be queued */
-EMsgPort *alarm_reply_port;
-static GIOChannel *alarm_reply_channel;
-
#define d(x) x
@@ -286,72 +282,12 @@
g_mutex_free (priv->mutex);
g_free (priv);
- e_thread_destroy(alarm_operation_thread);
- g_io_channel_unref(alarm_reply_channel);
- e_msgport_destroy(alarm_reply_port);
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
-static guint
-alarm_channel_setup(EMsgPort **port, GIOChannel **channel, GIOFunc func)
-{
- GSource *source;
- guint id;
-
- d (printf("%s:%d (alarm_channel_setup) - Channel Setup\n ", __FILE__, __LINE__));
- *port = e_msgport_new();
-#ifndef G_OS_WIN32
- *channel = g_io_channel_unix_new(e_msgport_fd(*port));
-#else
- *channel = g_io_channel_win32_new_socket(e_msgport_fd(*port));
-#endif
- source = g_io_create_watch(*channel, G_IO_IN);
- g_source_set_callback(source, (GSourceFunc)func, *port, NULL);
- g_source_set_can_recurse(source, FALSE);
- id = g_source_attach(source, NULL);
- g_source_unref(source);
-
- return id;
-}
-
-static void
-alarm_msg_destroy(EThread *e, EMsg *msg, void *data)
-{
- AlarmMsg *m = (AlarmMsg *)msg;
-
- /* Free the private */
- g_free (m->data); /* Mostly it is a structure allocated as a carrier*/
- g_free (m);
-}
-
-static gboolean
-alarm_msgport_replied(GIOChannel *source, GIOCondition cond, void *d)
-{
- EMsgPort *port = (EMsgPort *)d;
- EMsg *m;
-
- while (( m = e_msgport_get(port))) {
- d (printf("%s:%d (alarm_msgport_replied) - %p: Replied to GUI thread\n", __FILE__, __LINE__, m));
- alarm_msg_destroy(NULL, m, NULL);
- }
-
- return TRUE;
-}
-
-static void
-alarm_msg_received(EThread *e, EMsg *msg, void *data)
-{
- AlarmMsg *m = (AlarmMsg *)msg;
-
- d(printf("%s:%d (alarm_msg_received) - %p: Received at thread %" G_GINT64_MODIFIER "x\n", __FILE__, __LINE__, m, e_util_pthread_id(pthread_self())));
- if (m->receive_msg) {
- m->receive_msg (e, m, data);
- }
-}
-
/**
* alarm_notify_new:
*
@@ -363,23 +299,10 @@
AlarmNotify *
alarm_notify_new (void)
{
- AlarmNotify *an;
-
- d (printf("%s:%d (alarm_notify_new) - Alarm Notify New \n ", __FILE__, __LINE__));
-
- /* Create a thread for alarm queue operation*/
- alarm_channel_setup(&alarm_reply_port, &alarm_reply_channel, alarm_msgport_replied);
-
- alarm_operation_thread = e_thread_new(E_THREAD_QUEUE);
- e_thread_set_msg_destroy(alarm_operation_thread, alarm_msg_destroy, 0);
- e_thread_set_msg_received(alarm_operation_thread, alarm_msg_received, 0);
- e_thread_set_reply_port(alarm_operation_thread, alarm_reply_port);
-
- an = g_object_new (TYPE_ALARM_NOTIFY,
- "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
- NULL);
-
- return an;
+ return g_object_new (TYPE_ALARM_NOTIFY,
+ "poa", bonobo_poa_get_threaded (
+ ORBIT_THREAD_HINT_PER_REQUEST, NULL),
+ NULL);
}
static void
--- evolution-2.9.91/calendar/gui/alarm-notify/alarm-queue.c.kill-ethread 2007-01-03 10:27:57.000000000 -0500
+++ evolution-2.9.91/calendar/gui/alarm-notify/alarm-queue.c 2007-02-15 16:04:42.000000000 -0500
@@ -115,9 +115,6 @@
static int tray_blink_state = FALSE;
static AlarmNotify *an;
-/* Main Tasks thread for dealing with the global structures */
-extern EThread *alarm_operation_thread;
-
/* Structure that stores a client we are monitoring */
typedef struct {
/* Monitored client */
@@ -199,6 +196,40 @@
static void load_alarms_for_today (ClientAlarms *ca);
static void midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data);
+/* Simple asynchronous message dispatcher */
+
+typedef struct _Message Message;
+typedef void (*MessageFunc) (Message *msg);
+
+struct _Message {
+ MessageFunc func;
+};
+
+static void
+message_proxy (Message *msg)
+{
+ g_return_if_fail (msg->func != NULL);
+
+ msg->func (msg);
+}
+
+static gpointer
+create_thread_pool (void)
+{
+ /* once created, run forever */
+ return g_thread_pool_new ((GFunc) message_proxy, NULL, 1, FALSE, NULL);
+}
+
+static void
+message_push (Message *msg)
+{
+ static GOnce once = G_ONCE_INIT;
+
+ g_once (&once, (GThreadFunc) create_thread_pool, NULL);
+
+ g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
+}
+
/* Queues an alarm trigger for midnight so that we can load the next day's worth
* of alarms.
*/
@@ -237,47 +268,41 @@
}
struct _midnight_refresh_msg {
+ Message header;
gboolean remove;
};
/* Loads the alarms for the new day every midnight */
static void
-midnight_refresh_async (EThread *e, AlarmMsg *msg, void *data)
+midnight_refresh_async (struct _midnight_refresh_msg *msg)
{
- struct _midnight_refresh_msg *list = msg->data;
-
d(printf("%s:%d (midnight_refresh_async) \n",__FILE__, __LINE__));
/* Re-load the alarms for all clients */
g_hash_table_foreach (client_alarms_hash, add_client_alarms_cb, NULL);
/* Re-schedule the midnight update */
- if (list->remove && midnight_refresh_id != NULL) {
+ if (msg->remove && midnight_refresh_id != NULL) {
d(printf("%s:%d (midnight_refresh_async) - Reschedule the midnight update \n",__FILE__, __LINE__));
alarm_remove (midnight_refresh_id);
midnight_refresh_id = NULL;
}
queue_midnight_refresh ();
+
+ g_slice_free (struct _midnight_refresh_msg, msg);
}
static void
midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data)
{
- AlarmMsg *msg;
- struct _midnight_refresh_msg *list;
-
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = midnight_refresh_async;
-
- list = malloc (sizeof (struct _midnight_refresh_msg));
+ struct _midnight_refresh_msg *msg;
- list->remove = TRUE;
- msg->data = list;
+ msg = g_slice_new (struct _midnight_refresh_msg);
+ msg->header.func = (MessageFunc) midnight_refresh_async;
+ msg->remove = TRUE;
- d(printf("%s:%d (midnight_refresh_cb) - Invoking task for midnight refresh\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
/* Looks up a client in the client alarms hash table */
@@ -636,6 +661,7 @@
* alarms.
*/
struct _query_msg {
+ Message header;
ECal *client;
GList *objects;
gpointer data;
@@ -669,7 +695,7 @@
}
static void
-query_objects_changed_async (EThread *e, AlarmMsg *msg, void *data)
+query_objects_changed_async (struct _query_msg *msg)
{
ClientAlarms *ca;
time_t from, day_end;
@@ -678,13 +704,12 @@
icaltimezone *zone;
CompQueuedAlarms *cqa;
GList *l;
- struct _query_msg *list = msg->data;
ECal *client;
GList *objects;
- client = list->client;
- ca = list->data;
- objects = list->objects;
+ client = msg->client;
+ ca = msg->data;
+ objects = msg->objects;
from = config_data_get_last_notification_time ();
if (from == -1)
@@ -773,43 +798,38 @@
comp = NULL;
}
g_list_free (objects);
+
+ g_slice_free (struct _query_msg, msg);
}
static void
query_objects_changed_cb (ECal *client, GList *objects, gpointer data)
{
- AlarmMsg *msg;
- struct _query_msg *list;
+ struct _query_msg *msg;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = query_objects_changed_async;
- list = malloc (sizeof (struct _query_msg));
- list->client = client;
- list->objects = duplicate_ical (objects);
- list->data = data;
- msg->data = list;
-
- d(printf("%s:%d (query_objects_changed_cb) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ msg = g_slice_new (struct _query_msg);
+ msg->header.func = (MessageFunc) query_objects_changed_async;
+ msg->client = client;
+ msg->objects = duplicate_ical (objects);
+ msg->data = data;
+ message_push ((Message *) msg);
}
/* Called when a calendar component is removed; we must delete its corresponding
* alarms.
*/
static void
-query_objects_removed_async (EThread *e, AlarmMsg *msg, void *data)
+query_objects_removed_async (struct _query_msg *msg)
{
ClientAlarms *ca;
GList *l;
- struct _query_msg *list = msg->data;
ECal *client;
GList *objects;
- client = list->client;
- ca = list->data;
- objects = list->objects;
+ client = msg->client;
+ ca = msg->data;
+ objects = msg->objects;
d(printf("%s:%d (query_objects_removed_async) - Removing %d objects\n",__FILE__, __LINE__, g_list_length(objects)));
@@ -822,27 +842,22 @@
}
g_list_free (objects);
+
+ g_slice_free (struct _query_msg, msg);
}
static void
query_objects_removed_cb (ECal *client, GList *objects, gpointer data)
{
- AlarmMsg *msg;
- struct _query_msg *list;
-
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = query_objects_removed_async;
-
- list = malloc (sizeof (struct _query_msg));
- list->client = client;
- list->objects = duplicate_ecal (objects);
- list->data = data;
- msg->data = list;
+ struct _query_msg *msg;
- d(printf("%s:%d (query_objects_removed_cb) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ msg = g_slice_new (struct _query_msg);
+ msg->header.func = (MessageFunc) query_objects_removed_async;
+ msg->client = client;
+ msg->objects = duplicate_ecal (objects);
+ msg->data = data;
+ message_push ((Message *) msg);
}
@@ -989,20 +1004,19 @@
}
static void
-on_dialog_objs_removed_async (EThread *e, AlarmMsg *msg, void *data)
+on_dialog_objs_removed_async (struct _query_msg *msg)
{
const char *our_uid;
GList *l;
TrayIconData *tray_data;
- struct _query_msg *list = msg->data;
ECal *client;
GList *objects;
d(printf("%s:%d (on_dialog_objs_removed_async)\n",__FILE__, __LINE__));
- client = list->client;
- tray_data = list->data;
- objects = list->objects;
+ client = msg->client;
+ tray_data = msg->data;
+ objects = msg->objects;
e_cal_component_get_uid (tray_data->comp, &our_uid);
g_return_if_fail (our_uid && *our_uid);
@@ -1020,37 +1034,33 @@
tray_data = NULL;
}
}
+
+ g_slice_free (struct _query_msg, msg);
}
static void
on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data)
{
- AlarmMsg *msg;
- struct _query_msg *list;
+ struct _query_msg *msg;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = on_dialog_objs_removed_async;
-
- list = malloc (sizeof (struct _query_msg));
- list->client = client;
- list->objects = objects;
- list->data = data;
- msg->data = list;
+ msg = g_slice_new (struct _query_msg);
+ msg->header.func = (MessageFunc) on_dialog_objs_removed_async;
+ msg->client = client;
+ msg->objects = objects;
+ msg->data = data;
- d(printf("%s:%d (on_dialog_objs_removed_cb) - Posting a task \n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
struct _tray_cqa_msg {
+ Message header;
CompQueuedAlarms *cqa;
};
static void
-tray_list_remove_cqa_async(EThread *e, AlarmMsg *msg, void *data)
+tray_list_remove_cqa_async (struct _tray_cqa_msg *msg)
{
- struct _tray_cqa_msg *tmsg = msg->data;
- CompQueuedAlarms *cqa = tmsg->cqa;
+ CompQueuedAlarms *cqa = msg->cqa;
GList *list = tray_icons_list;
d(printf("%s:%d (tray_list_remove_cqa_async) - Removing CQA %p from tray list\n",__FILE__, __LINE__, cqa));
@@ -1087,28 +1097,25 @@
gtk_tree_selection_select_iter (sel, &iter);
}
}
+
+ g_slice_free (struct _tray_cqa_msg, msg);
}
static void
tray_list_remove_cqa (CompQueuedAlarms *cqa)
{
- AlarmMsg *msg;
- struct _tray_cqa_msg *list;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = tray_list_remove_cqa_async;
-
- list = malloc (sizeof (struct _tray_cqa_msg));
- list->cqa = cqa;
- msg->data = list;
+ struct _tray_cqa_msg *msg;
+
+ msg = g_slice_new (struct _tray_cqa_msg);
+ msg->header.func = (MessageFunc) tray_list_remove_cqa_async;
+ msg->cqa = cqa;
- d(printf("%s:%d (tray_list_remove_cqa) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
/* Callback used from the alarm notify dialog */
static void
-tray_list_remove_async(EThread *e, AlarmMsg *msg, void *data)
+tray_list_remove_async (Message *msg)
{
GList *list = tray_icons_list;
@@ -1138,55 +1145,50 @@
} else
list = list->next;
}
+
+ g_slice_free (Message, msg);
}
static void
-tray_list_remove_icons ()
+tray_list_remove_icons (void)
{
- AlarmMsg *msg;
-
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = tray_list_remove_async;
+ Message *msg;
- msg->data = NULL;
+ msg = g_slice_new (Message);
+ msg->func = tray_list_remove_async;
- d(printf("%s:%d (tray_list_remove_icons) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push (msg);
}
struct _tray_msg {
+ Message header;
TrayIconData *data;
};
static void
-tray_list_remove_data_async(EThread *e, AlarmMsg *msg, void *data)
+tray_list_remove_data_async (struct _tray_msg *msg)
{
- struct _tray_msg *tmsg = msg->data;
- TrayIconData *tray_data = tmsg->data;
+ TrayIconData *tray_data = msg->data;
d(printf("%s:%d (tray_list_remove_data_async) - Removing %p from tray list\n",__FILE__, __LINE__, tray_data));
tray_icons_list = g_list_remove_all (tray_icons_list, tray_data);
free_tray_icon_data (tray_data);
tray_data = NULL;
+
+ g_slice_free (struct _tray_msg, msg);
}
static void
tray_list_remove_data (TrayIconData *data)
{
- AlarmMsg *msg;
- struct _tray_msg *list;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = tray_list_remove_data_async;
-
- list = malloc (sizeof (struct _tray_msg));
- list->data = data;
- msg->data = list;
+ struct _tray_msg *msg;
+
+ msg = g_slice_new (struct _tray_msg);
+ msg->header.func = (MessageFunc) tray_list_remove_data_async;
+ msg->data = data;
- d(printf("%s:%d (tray_list_remove_data) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
static void
@@ -1394,29 +1396,24 @@
/* Add a new data to tray list */
static void
-tray_list_add_async (EThread *e, AlarmMsg *msg, void *data)
+tray_list_add_async (struct _tray_msg *msg)
{
- struct _tray_msg *list = msg->data;
- d(printf("%s:%d (tray_list_add_async) - Add %p\n",__FILE__, __LINE__, list->data));
- tray_icons_list = g_list_prepend (tray_icons_list, list->data);
+ d(printf("%s:%d (tray_list_add_async) - Add %p\n",__FILE__, __LINE__, msg->data));
+ tray_icons_list = g_list_prepend (tray_icons_list, msg->data);
+
+ g_slice_free (struct _tray_msg, msg);
}
static void
tray_list_add_new (TrayIconData *data)
{
- AlarmMsg *msg;
- struct _tray_msg *list;
+ struct _tray_msg *msg;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = tray_list_add_async;
-
- list = malloc (sizeof (struct _tray_msg));
- list->data = data;
- msg->data = list;
-
- d(printf("%s:%d (tray_list_add_new) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ msg = g_slice_new (struct _tray_msg);
+ msg->header.func = (MessageFunc) tray_list_add_async;
+ msg->data = data;
+
+ message_push ((Message *) msg);
}
/* Performs notification of a display alarm */
@@ -1840,21 +1837,13 @@
new_midnight = time_day_end_with_zone (time (NULL), zone);
if (new_midnight > midnight) {
- AlarmMsg *msg;
- struct _midnight_refresh_msg *list;
-
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = midnight_refresh_async;
-
- list = malloc (sizeof (struct _midnight_refresh_msg));
+ struct _midnight_refresh_msg *msg;
- list->remove = FALSE;
- /* We dont need it. So set it to NULL */
- msg->data = list;
+ msg = g_slice_new (struct _midnight_refresh_msg);
+ msg->header.func = (MessageFunc) midnight_refresh_async;
+ msg->remove = FALSE;
- d(printf("%s:%d (check_midnight_refresh) - Posting a task to refresh\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
return TRUE;
@@ -1985,14 +1974,15 @@
}
struct _alarm_client_msg {
+ Message header;
ECal *client;
};
-static void alarm_queue_add_async (EThread *e, AlarmMsg *msg, void *data)
+static void
+alarm_queue_add_async (struct _alarm_client_msg *msg)
{
ClientAlarms *ca;
- struct _alarm_client_msg *list = msg->data;
- ECal *client = list->client;
+ ECal *client = msg->client;
g_return_if_fail (alarm_queue_inited);
g_return_if_fail (client != NULL);
@@ -2023,6 +2013,8 @@
G_CALLBACK (cal_opened_cb),
ca);
}
+
+ g_slice_free (struct _alarm_client_msg, msg);
}
/**
@@ -2042,20 +2034,13 @@
void
alarm_queue_add_client (ECal *client)
{
- AlarmMsg *msg;
- struct _alarm_client_msg *list;
+ struct _alarm_client_msg *msg;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = alarm_queue_add_async;
-
- list = malloc (sizeof (struct _alarm_client_msg));
- list->client = client;
- g_object_ref (client);
- msg->data = list;
+ msg = g_slice_new (struct _alarm_client_msg);
+ msg->header.func = (MessageFunc) alarm_queue_add_async;
+ msg->client = g_object_ref (client);
- d(printf("%s:%d (alarm_queue_add_client) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
/* Removes a component an its alarms */
@@ -2107,11 +2092,10 @@
* Removes a calendar client from the alarm queueing system.
**/
static void
-alarm_queue_remove_async (EThread *e, AlarmMsg *msg, void *data)
+alarm_queue_remove_async (struct _alarm_client_msg *msg)
{
ClientAlarms *ca;
- struct _alarm_client_msg *list = msg->data;
- ECal *client = list->client;
+ ECal *client = msg->client;
g_return_if_fail (alarm_queue_inited);
g_return_if_fail (client != NULL);
@@ -2148,24 +2132,20 @@
g_free (ca);
g_hash_table_remove (client_alarms_hash, client);
+
+ g_slice_free (struct _alarm_client_msg, msg);
}
void
alarm_queue_remove_client (ECal *client)
{
- AlarmMsg *msg;
- struct _alarm_client_msg *list;
+ struct _alarm_client_msg *msg;
- /* These two structures will be freed by the msg destroy function*/
- msg = malloc (sizeof (AlarmMsg));
- msg->receive_msg = alarm_queue_remove_async;
-
- list = malloc (sizeof (struct _alarm_client_msg));
- list->client = client;
- msg->data = list;
+ msg = g_slice_new (struct _alarm_client_msg);
+ msg->header.func = (MessageFunc) alarm_queue_remove_async;
+ msg->client = client;
- d(printf("%s:%d (alarm_queue_remove_client) - Posting a task\n",__FILE__, __LINE__));
- e_thread_put(alarm_operation_thread, (EMsg *)msg);
+ message_push ((Message *) msg);
}
/* Update non-time related variables for various structures on modification of an existing component