Index: camel/camel-private.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-private.h,v
retrieving revision 1.37
diff -u -p -r1.37 camel-private.h
--- camel/camel-private.h	8 Dec 2005 08:59:32 -0000	1.37
+++ camel/camel-private.h	5 Dec 2006 18:16:30 -0000
@@ -82,7 +82,7 @@ struct _CamelSessionPrivate {
 
 	int thread_id;
 	GHashTable *thread_active;
-	EThread *thread_queue;
+	GThreadPool *thread_pool;
 
 	GHashTable *thread_msg_op;
 };
Index: camel/camel-session.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-session.c,v
retrieving revision 1.117
diff -u -p -r1.117 camel-session.c
--- camel/camel-session.c	10 Jan 2006 07:56:46 -0000	1.117
+++ camel/camel-session.c	5 Dec 2006 18:16:30 -0000
@@ -76,17 +76,22 @@ camel_session_init (CamelSession *sessio
 	session->priv->thread_lock = g_mutex_new();
 	session->priv->thread_id = 1;
 	session->priv->thread_active = g_hash_table_new(NULL, NULL);
-	session->priv->thread_queue = NULL;
+	session->priv->thread_pool = NULL;
 }
 
 static void
 camel_session_finalise (CamelObject *o)
 {
 	CamelSession *session = (CamelSession *)o;
+	GThreadPool *thread_pool = session->priv->thread_pool;
 	
 	g_hash_table_destroy(session->priv->thread_active);
-	if (session->priv->thread_queue)
-		e_thread_destroy(session->priv->thread_queue);
+
+	if (thread_pool != NULL) {
+		/* there should be no unprocessed tasks */
+		g_assert(g_thread_pool_unprocessed (thread_pool) == 0);
+		g_thread_pool_free(thread_pool, FALSE, FALSE);
+	}
 
 	g_free(session->storage_path);
 	
@@ -515,15 +520,9 @@ static void session_thread_msg_free(Came
 	g_free(msg);
 }
 
-static void session_thread_destroy(EThread *thread, CamelSessionThreadMsg *msg, CamelSession *session)
-{
-	d(printf("destroy message %p session %p\n", msg, session));
-	camel_session_thread_msg_free(session, msg);
-}
-
-static void session_thread_received(EThread *thread, CamelSessionThreadMsg *msg, CamelSession *session)
+static void
+session_thread_proxy(CamelSessionThreadMsg *msg, CamelSession *session)
 {
-	d(printf("receive message %p session %p\n", msg, session));
 	if (msg->ops->receive) {
 		CamelOperation *oldop;
 
@@ -531,22 +530,27 @@ static void session_thread_received(EThr
 		msg->ops->receive(session, msg);
 		camel_operation_register(oldop);
 	}
+
+	camel_session_thread_msg_free(session, msg);
 }
 
 static int session_thread_queue(CamelSession *session, CamelSessionThreadMsg *msg, int flags)
 {
+	GThreadPool *thread_pool;
 	int id;
 
 	CAMEL_SESSION_LOCK(session, thread_lock);
-	if (session->priv->thread_queue == NULL) {
-		session->priv->thread_queue = e_thread_new(E_THREAD_QUEUE);
-		e_thread_set_msg_destroy(session->priv->thread_queue, (EThreadFunc)session_thread_destroy, session);
-		e_thread_set_msg_received(session->priv->thread_queue, (EThreadFunc)session_thread_received, session);
+	thread_pool = session->priv->thread_pool;
+	if (thread_pool == NULL) {
+		thread_pool = g_thread_pool_new (
+			(GFunc) session_thread_proxy,
+			session, 1, FALSE, NULL);
+		session->priv->thread_pool = thread_pool;
 	}
 	CAMEL_SESSION_UNLOCK(session, thread_lock);
 
 	id = msg->id;
-	e_thread_put(session->priv->thread_queue, &msg->msg);
+	g_thread_pool_push(thread_pool, msg, NULL);
 
 	return id;
 }
Index: libedataserver/e-msgport.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-msgport.h,v
retrieving revision 1.4
diff -u -p -r1.4 e-msgport.h
--- libedataserver/e-msgport.h	16 Oct 2006 12:35:48 -0000	1.4
+++ libedataserver/e-msgport.h	5 Dec 2006 18:16:35 -0000
@@ -71,6 +71,7 @@ void e_msgport_reply(EMsg *msg);
 struct PRFileDesc *e_msgport_prfd(EMsgPort *mp);
 #endif
 
+#ifndef EDS_DISABLE_DEPRECATED
 /* e threads, a server thread with a message based request-response, and flexible queuing */
 typedef struct _EThread EThread;
 
@@ -92,6 +93,7 @@ void e_thread_set_reply_port(EThread *e,
 void e_thread_set_msg_received(EThread *e, EThreadFunc received, void *data);
 void e_thread_put(EThread *e, EMsg *msg);
 int e_thread_busy(EThread *e);
+#endif
 
 /* sigh, another mutex interface, this one allows different mutex types, portably */
 typedef struct _EMutex EMutex;
