Patch: make tny_camel_mime_part_decode_to_stream_async be really async
- From: José Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: make tny_camel_mime_part_decode_to_stream_async be really async
- Date: Wed, 03 Sep 2008 17:23:54 +0200
Hi,
Yes, we were using this function in main loop, and no, it wasn't
asynchronous really (the implementation was a quick "just make it
compile" hack). Then, this is an implementation creating the proper
thread so that, if you call the function from mainloop, it doesn't lock
it while it's saving.
Changelog entry would be:
* libtinymail-camel/tny-camel-mime-part.c
(tny_camel_mime_part_decode_to_stream_async_default): make it really
asynchronous, doing the operation in a separate thread.
--
José Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- libtinymail-camel/tny-camel-mime-part.c (revision 3756)
+++ libtinymail-camel/tny-camel-mime-part.c (working copy)
@@ -303,8 +303,20 @@
return FALSE;
}
-/* This one is just to fulfil the API requirements */
+static gpointer
+decode_to_stream_async_thread (gpointer userdata)
+{
+ DecodeAsyncInfo *info = (DecodeAsyncInfo *) userdata;
+ tny_mime_part_decode_to_stream (info->self, info->stream, &(info->err));
+
+ g_idle_add_full (G_PRIORITY_HIGH,
+ decode_async_callback,
+ info, decode_async_destroyer);
+ return NULL;
+
+}
+
static void
tny_camel_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data)
{
@@ -317,18 +329,18 @@
{
DecodeAsyncInfo *info = g_slice_new0 (DecodeAsyncInfo);
- tny_mime_part_decode_to_stream (self, stream, NULL);
-
info->self = g_object_ref (self);
info->stream = g_object_ref (stream);
info->callback = callback;
info->user_data = user_data;
info->err = NULL;
- g_idle_add_full (G_PRIORITY_HIGH,
- decode_async_callback,
- info, decode_async_destroyer);
-
+ if (g_thread_create (decode_to_stream_async_thread, info, FALSE, &(info->err)) == FALSE) {
+ g_idle_add_full (G_PRIORITY_HIGH,
+ decode_async_callback,
+ info, decode_async_destroyer);
+ }
+
return;
}
Index: ChangeLog
===================================================================
--- ChangeLog (revision 3756)
+++ ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2008-09-03 Jose Dapena Paz <jdapena igalia com>
+
+ * libtinymail-camel/tny-camel-mime-part.c
+ (tny_camel_mime_part_decode_to_stream_async_default): make it really
+ asynchronous, doing the operation in a separate thread.
+
2008-09-03 Sergio Villar Senin <svillar igalia com>
* libtinymail-camel/tny-camel-folder.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]