aboutsummaryrefslogtreecommitdiffstats
path: root/mail/test-thread.c
diff options
context:
space:
mode:
authorPeter Williams <peterw@src.gnome.org>2000-08-11 01:30:50 +0800
committerPeter Williams <peterw@src.gnome.org>2000-08-11 01:30:50 +0800
commit8cb514d6dd9497893a35a089d07a132d51263ee7 (patch)
tree9f4e5d1f929da7e0be900919753d419fe4c9c61a /mail/test-thread.c
parentbcbb63c59f80eb4e684036c5ef58ab141fb01b03 (diff)
downloadgsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.gz
gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.tar.zst
gsoc2013-evolution-8cb514d6dd9497893a35a089d07a132d51263ee7.zip
Merge with camel-async.
svn path=/trunk/; revision=4687
Diffstat (limited to 'mail/test-thread.c')
-rw-r--r--mail/test-thread.c149
1 files changed, 113 insertions, 36 deletions
diff --git a/mail/test-thread.c b/mail/test-thread.c
index b9fb5bb0b2..7a389605ec 100644
--- a/mail/test-thread.c
+++ b/mail/test-thread.c
@@ -8,30 +8,44 @@
#include <stdio.h>
#include "mail-threads.h"
-#ifdef ENABLE_BROKEN_THREADS
-
-static void op_1( gpointer userdata );
-static void op_2( gpointer userdata );
-static void op_3( gpointer userdata );
-static void op_4( gpointer userdata );
-static void op_5( gpointer userdata );
-static void done( gpointer userdata );
+static gchar *desc_1 (gpointer in, gboolean gerund);
+static void op_1( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_2 (gpointer in, gboolean gerund);
+static void op_2( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_3 (gpointer in, gboolean gerund);
+static void op_3( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_4 (gpointer in, gboolean gerund);
+static void op_4( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_5 (gpointer in, gboolean gerund);
+static void op_5( gpointer in, gpointer op, CamelException *ex );
+static gchar *desc_6 (gpointer in, gboolean gerund);
+static gchar *desc_7 (gpointer in, gboolean gerund);
+static gchar *desc_8 (gpointer in, gboolean gerund);
+static void done( gpointer in, gpointer op, CamelException *ex );
+static void exception( gpointer in, gpointer op, CamelException *ex );
static gboolean queue_ops( void );
+const mail_operation_spec spec1 = { desc_1, 0, NULL, op_1, done };
+const mail_operation_spec spec2 = { desc_2, 0, NULL, op_2, done };
+const mail_operation_spec spec3 = { desc_3, 0, NULL, op_3, done };
+const mail_operation_spec spec4 = { desc_4, 0, NULL, op_4, NULL };
+const mail_operation_spec spec5 = { desc_5, 0, NULL, op_5, done };
+const mail_operation_spec spec6 = { desc_6, 0, exception, op_4, NULL };
+const mail_operation_spec spec7 = { desc_7, 0, NULL, exception, NULL };
+const mail_operation_spec spec8 = { desc_8, 0, NULL, op_4, exception };
+
static gboolean queue_ops( void )
{
int i;
- gchar buf[32];
g_message( "Top of queue_ops" );
- mail_operation_try( "The Crawling Progress Bar of Doom", op_1, done, "op1 finished" );
- mail_operation_try( "The Mysterious Message Setter", op_2, done, "op2 finished" );
- mail_operation_try( "The Error Dialog of No Return", op_3, done, "op3 finished" );
+ mail_operation_queue( &spec1, "op1 finished", FALSE );
+ mail_operation_queue( &spec2, "op2 finished", FALSE );
+ mail_operation_queue( &spec3, "op3 finished", FALSE );
for( i = 0; i < 3; i++ ) {
- sprintf( buf, "Queue Filler %d", i );
- mail_operation_try( buf, op_4, NULL, GINT_TO_POINTER( i ) );
+ mail_operation_queue( &spec4, GINT_TO_POINTER( i ), FALSE );
}
g_message( "Waiting for finish..." );
@@ -39,20 +53,23 @@ static gboolean queue_ops( void )
g_message( "Ops done -- queue some more!" );
- mail_operation_try( "Progress Bar Redux", op_1, NULL, NULL );
+ mail_operation_queue( &spec1, "done a second time", FALSE );
g_message( "Waiting for finish again..." );
mail_operation_wait_for_finish();
g_message( "Ops done -- more, more!" );
- mail_operation_try( "Dastardly Password Stealer", op_5, NULL, NULL );
+ mail_operation_queue( &spec5, "passwords stolen", FALSE );
for( i = 0; i < 3; i++ ) {
- sprintf( buf, "Queue Filler %d", i );
- mail_operation_try( buf, op_4, NULL, GINT_TO_POINTER( i ) );
+ mail_operation_queue( &spec4, GINT_TO_POINTER( i ), FALSE );
}
+ mail_operation_queue( &spec6, NULL, FALSE );
+ mail_operation_queue( &spec7, NULL, FALSE );
+ mail_operation_queue( &spec8, NULL, FALSE );
+
g_message( "Waiting for finish AGAIN..." );
mail_operation_wait_for_finish();
g_message( "Ops done again. Exiting 0" );
@@ -60,7 +77,12 @@ static gboolean queue_ops( void )
return FALSE;
}
-static void op_1( gpointer userdata )
+static void exception( gpointer in, gpointer op, CamelException *ex )
+{
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, "I don't feel like it.");
+}
+
+static void op_1( gpointer in, gpointer op, CamelException *ex )
{
gfloat pct;
@@ -73,7 +95,7 @@ static void op_1( gpointer userdata )
}
}
-static void op_2( gpointer userdata )
+static void op_2( gpointer in, gpointer op, CamelException *ex )
{
int i;
@@ -87,7 +109,7 @@ static void op_2( gpointer userdata )
sleep( 1 );
}
-static void op_3( gpointer userdata )
+static void op_3( gpointer in, gpointer op, CamelException *ex )
{
gfloat pct;
@@ -103,14 +125,14 @@ static void op_3( gpointer userdata )
sleep( 1 );
}
-static void op_4( gpointer userdata )
+static void op_4( gpointer in, gpointer op, CamelException *ex )
{
mail_op_hide_progressbar();
- mail_op_set_message( "Filler # %d", GPOINTER_TO_INT( userdata ) );
+ mail_op_set_message( "Filler # %d", GPOINTER_TO_INT( in ) );
sleep( 1 );
}
-static void op_5( gpointer userdata )
+static void op_5( gpointer in, gpointer op, CamelException *ex )
{
gchar *pass;
gboolean ret;
@@ -128,26 +150,81 @@ static void op_5( gpointer userdata )
sleep( 1 );
}
-static void done( gpointer userdata )
+static void done( gpointer in, gpointer op, CamelException *ex )
{
- g_message( "Operation done: %s", (gchar *) userdata );
+ g_message( "Operation done: %s", (gchar *) in );
}
-int main( int argc, char **argv )
+static gchar *desc_1 (gpointer in, gboolean gerund)
{
- g_thread_init( NULL );
- gnome_init( "test-thread", "0.0", argc, argv );
- gtk_idle_add( (GtkFunction) queue_ops, NULL );
- gtk_main();
- return 0;
+ if (gerund)
+ return g_strdup ("Showing the Crawling Progress Bar of Doom");
+ else
+ return g_strdup ("Progress Bar");
+}
+
+static gchar *desc_2 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Exploring the Mysterious Message Setter");
+ else
+ return g_strdup ("Explore");
+}
+
+static gchar *desc_3 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Dare the Error Dialog of No Return");
+ else
+ return g_strdup ("Dare");
+}
+
+static gchar *desc_4 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup_printf ("Filling Queue Space -- %d", GPOINTER_TO_INT (in));
+ else
+ return g_strdup_printf ("Filler -- %d", GPOINTER_TO_INT (in));
+}
+
+static gchar *desc_5 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Stealing your Password");
+ else
+ return g_strdup ("The Dastardly Password Stealer");
+}
+
+static gchar *desc_6 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception on setup");
+ else
+ return g_strdup ("Exception on setup");
+}
+
+static gchar *desc_7 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception in process");
+ else
+ return g_strdup ("Exception coming soon");
+}
+
+static gchar *desc_8 (gpointer in, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup ("Setting exception in cleanup");
+ else
+ return g_strdup ("Exception in cleanup");
}
-#else
int main( int argc, char **argv )
{
- g_message( "Threads aren't enabled, so they cannot be tested." );
+ g_thread_init( NULL );
+ gnome_init( "test-thread", "0.0", argc, argv );
+ gtk_idle_add( (GtkFunction) queue_ops, NULL );
+ gtk_main();
return 0;
}
-
-#endif