From bd8d314c29ac546daca8a6ba0a4dbabd5285725d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 21 Apr 2011 15:07:36 -0700 Subject: [PATCH] Converted to new thread API. --- libguac/include/thread.h | 2 +- libguac/src/client.c | 14 +++++++------- libguac/src/thread.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libguac/include/thread.h b/libguac/include/thread.h index b0372e5a..ae537b1f 100644 --- a/libguac/include/thread.h +++ b/libguac/include/thread.h @@ -57,7 +57,7 @@ typedef uintptr_t guac_thread_t; #endif -void guac_thread_create(guac_thread_t* thread, void*(*function)(void*), void* data); +int guac_thread_create(guac_thread_t* thread, void*(*function)(void*), void* data); void guac_thread_join(guac_thread_t thread); #endif diff --git a/libguac/src/client.c b/libguac/src/client.c index c11ebd05..47ed4636 100644 --- a/libguac/src/client.c +++ b/libguac/src/client.c @@ -39,8 +39,8 @@ #include #include #include -#include +#include "thread.h" #include "log.h" #include "guacio.h" #include "protocol.h" @@ -363,21 +363,21 @@ void* __guac_client_input_thread(void* data) { int guac_start_client(guac_client* client) { - pthread_t input_thread, output_thread; + guac_thread_t input_thread, output_thread; - if (pthread_create(&output_thread, NULL, __guac_client_output_thread, (void*) client)) { + if (guac_thread_create(&output_thread, __guac_client_output_thread, (void*) client)) { return -1; } - if (pthread_create(&input_thread, NULL, __guac_client_input_thread, (void*) client)) { + if (guac_thread_create(&input_thread, __guac_client_input_thread, (void*) client)) { guac_client_stop(client); - pthread_join(output_thread, NULL); + guac_thread_join(output_thread); return -1; } /* Wait for I/O threads */ - pthread_join(input_thread, NULL); - pthread_join(output_thread, NULL); + guac_thread_join(input_thread); + guac_thread_join(output_thread); /* Done */ return 0; diff --git a/libguac/src/thread.c b/libguac/src/thread.c index c22dc3a4..a449cd52 100644 --- a/libguac/src/thread.c +++ b/libguac/src/thread.c @@ -44,9 +44,9 @@ #include #endif -void guac_thread_create(guac_thread_t* thread, void*(*function)(void*), void* data) { +int guac_thread_create(guac_thread_t* thread, void*(*function)(void*), void* data) { #ifdef HAVE_LIBPTHREAD - pthread_create(thread, NULL, function, data); + return pthread_create(thread, NULL, function, data); #elif defined(__MINGW32__) *thread = _beginthreadex(NULL, 0, function, data, 0 /* Create running */, NULL);