[evolution-data-server/mmeeks-gdbus-import] Use Gthread instead of pthread



commit bc3ce97ff647b86fbb6e2612fa98038716739d37
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Wed Mar 3 08:10:56 2010 +0530

    Use Gthread instead of pthread

 camel/providers/imapx/camel-imapx-server.c |   23 +++++++++++++----------
 camel/providers/imapx/camel-imapx-server.h |    2 +-
 2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 2e1b56d..33183bc 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -270,7 +270,7 @@ typedef struct _CamelIMAPXIdle CamelIMAPXIdle;
 struct _CamelIMAPXIdle {
 	GMutex *idle_lock;
 	EFlag *idle_start_watch;
-	pthread_t idle_thread_id;
+	GThread *idle_thread;
 
 	gboolean idle_issue_done;
 	gboolean in_idle;
@@ -1823,7 +1823,7 @@ imapx_server_fetch_new_messages (CamelIMAPXServer *is, CamelFolder *folder, gboo
 }
 
 static gpointer
-idle_thread (gpointer data)
+imapx_idle_thread (gpointer data)
 {
 	CamelException *ex = camel_exception_new ();
 	CamelIMAPXServer *is = (CamelIMAPXServer *) data;
@@ -1851,6 +1851,7 @@ idle_thread (gpointer data)
 	}
 
 	camel_exception_free (ex);
+	is->idle->idle_thread = NULL;
 	return NULL;
 }
 
@@ -1886,13 +1887,15 @@ imapx_exit_idle (CamelIMAPXServer *is)
 
 	IDLE_LOCK (idle);
 
-	if (idle->idle_thread_id) {
+	if (idle->idle_thread) {
 		idle->idle_exit = TRUE;
 		e_flag_set (idle->idle_start_watch);
 
-		pthread_join (idle->idle_thread_id, NULL);
+		if (idle->idle_thread)
+			g_thread_join (idle->idle_thread);
 	}
 
+	idle->idle_thread = NULL;
 	IDLE_UNLOCK (idle);
 
 	g_mutex_free (idle->idle_lock);
@@ -1913,9 +1916,9 @@ imapx_start_idle (CamelIMAPXServer *is)
 
 	IDLE_LOCK (idle);
 
-	if (!idle->idle_thread_id) {
+	if (!idle->idle_thread) {
 		idle->idle_start_watch = e_flag_new ();
-		pthread_create (&idle->idle_thread_id, NULL, idle_thread, is);
+		idle->idle_thread = g_thread_create ((GThreadFunc) imapx_idle_thread, is, TRUE, NULL);
 	} else
 		e_flag_set (idle->idle_start_watch);
 
@@ -3541,6 +3544,7 @@ quit:
 	if (op)
 		camel_operation_unref (op);
 
+	is->parser_thread = NULL;
 	return NULL;
 }
 
@@ -3676,7 +3680,6 @@ camel_imapx_server_connect(CamelIMAPXServer *is, gint state)
 
 	CAMEL_SERVICE_REC_LOCK (is->store, connect_lock);
 	if (state) {
-		pthread_t id;
 		CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 
 		if (is->state == IMAPX_AUTHENTICATED || is->state == IMAPX_SELECTED) {
@@ -3692,8 +3695,7 @@ camel_imapx_server_connect(CamelIMAPXServer *is, gint state)
 			goto exit;
 		}
 
-		pthread_create(&id, NULL, imapx_parser_thread, is);
-		is->parser_thread_id = id;
+		is->parser_thread = g_thread_create((GThreadFunc) imapx_parser_thread, is, TRUE, NULL);
 		ret = TRUE;
 	} else {
 		imapx_disconnect (is);
@@ -3703,7 +3705,8 @@ camel_imapx_server_connect(CamelIMAPXServer *is, gint state)
 
 		CAMEL_SERVICE_REC_UNLOCK (is->store, connect_lock);
 
-		pthread_join (is->parser_thread_id, NULL);
+		if (is->parser_thread)
+			g_thread_join (is->parser_thread);
 		return TRUE;
 	}
 
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index 283b8e8..98fa3e1 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -91,7 +91,7 @@ struct _CamelIMAPXServer {
 
 	/* connect_lock used for locking input stream locking and 
 	   ostream_lock for locking output stream */
-	pthread_t parser_thread_id;
+	GThread *parser_thread;
 	GStaticRecMutex ostream_lock;
 
 	/* Idle */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]