aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-store.c
diff options
context:
space:
mode:
author6 <NotZed@Ximian.com>2001-09-07 09:19:47 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-09-07 09:19:47 +0800
commit8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d (patch)
tree70c5af2a314ccc2ae6622aa1c5493f78c888f59b /camel/providers/imap/camel-imap-store.c
parent0256665bc7e65c13b4026873f8c95fcf3d9251e3 (diff)
downloadgsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar.gz
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar.bz2
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar.lz
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar.xz
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.tar.zst
gsoc2013-evolution-8e7d0e31cb1a6ac4c0b5f58522ac6b468b872f9d.zip
Thread function to perform filtering. (filter_free): Free the filter
2001-09-06 <NotZed@Ximian.com> * providers/imap/camel-imap-folder.c (filter_proc): Thread function to perform filtering. (filter_free): Free the filter object. (camel_imap_folder_changed): If we have threads enabled, then queue up a request to perform filtering. For bug #4422. * providers/imap/camel-imap-store.c (camel_imap_msg_new): Create a new 'imap msg'. (camel_imap_msg_queue): Queue an 'imap msg'. (async_received): Handle receiving of imap msg in async thread. (async_destroy): Handle destroying of imap msg. (camel_imap_store_finalize): Destroy thread when done. (camel_imap_store_init): Setup thread. * providers/imap/camel-imap-store.h: Added an ethread to the store, for async processing. svn path=/trunk/; revision=12666
Diffstat (limited to 'camel/providers/imap/camel-imap-store.c')
-rw-r--r--camel/providers/imap/camel-imap-store.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 10794f1270..ee5c0800fb 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -158,10 +158,52 @@ camel_imap_store_finalize (CamelObject *object)
#ifdef ENABLE_THREADS
e_mutex_destroy (imap_store->priv->command_lock);
+ e_thread_destroy(imap_store->async_thread);
#endif
g_free (imap_store->priv);
}
+#ifdef ENABLE_THREADS
+static void async_destroy(EThread *et, EMsg *em, void *data)
+{
+ CamelImapStore *imap_store = data;
+ CamelImapMsg *msg = (CamelImapMsg *)em;
+
+ if (msg->free)
+ msg->free(imap_store, msg);
+
+ g_free(msg);
+}
+
+static void async_received(EThread *et, EMsg *em, void *data)
+{
+ CamelImapStore *imap_store = data;
+ CamelImapMsg *msg = (CamelImapMsg *)em;
+
+ if (msg->receive)
+ msg->receive(imap_store, msg);
+}
+
+CamelImapMsg *camel_imap_msg_new(void (*receive)(CamelImapStore *store, struct _CamelImapMsg *m),
+ void (*free)(CamelImapStore *store, struct _CamelImapMsg *m),
+ size_t size)
+{
+ CamelImapMsg *msg;
+
+ g_assert(size >= sizeof(*msg));
+
+ msg = g_malloc0(size);
+ msg->receive = receive;
+ msg->free = free;
+}
+
+void camel_imap_msg_queue(CamelImapStore *store, CamelImapMsg *msg)
+{
+ e_thread_put(store->async_thread, (EMsg *)msg);
+}
+
+#endif
+
static void
camel_imap_store_init (gpointer object, gpointer klass)
{
@@ -183,6 +225,9 @@ camel_imap_store_init (gpointer object, gpointer klass)
imap_store->priv = g_malloc0 (sizeof (*imap_store->priv));
#ifdef ENABLE_THREADS
imap_store->priv->command_lock = e_mutex_new (E_MUTEX_REC);
+ imap_store->async_thread = e_thread_new(E_THREAD_QUEUE);
+ e_thread_set_msg_destroy(imap_store->async_thread, async_destroy, imap_store);
+ e_thread_set_msg_received(imap_store->async_thread, async_received, imap_store);
#endif
}