Converted to new thread API.

This commit is contained in:
Michael Jumper 2011-04-21 15:07:36 -07:00
parent c97875d5c8
commit bd8d314c29
3 changed files with 10 additions and 10 deletions

View File

@ -57,7 +57,7 @@ typedef uintptr_t guac_thread_t;
#endif #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); void guac_thread_join(guac_thread_t thread);
#endif #endif

View File

@ -39,8 +39,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <pthread.h>
#include "thread.h"
#include "log.h" #include "log.h"
#include "guacio.h" #include "guacio.h"
#include "protocol.h" #include "protocol.h"
@ -363,21 +363,21 @@ void* __guac_client_input_thread(void* data) {
int guac_start_client(guac_client* client) { 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; 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); guac_client_stop(client);
pthread_join(output_thread, NULL); guac_thread_join(output_thread);
return -1; return -1;
} }
/* Wait for I/O threads */ /* Wait for I/O threads */
pthread_join(input_thread, NULL); guac_thread_join(input_thread);
pthread_join(output_thread, NULL); guac_thread_join(output_thread);
/* Done */ /* Done */
return 0; return 0;

View File

@ -44,9 +44,9 @@
#include <process.h> #include <process.h>
#endif #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 #ifdef HAVE_LIBPTHREAD
pthread_create(thread, NULL, function, data); return pthread_create(thread, NULL, function, data);
#elif defined(__MINGW32__) #elif defined(__MINGW32__)
*thread = _beginthreadex(NULL, 0, *thread = _beginthreadex(NULL, 0,
function, data, 0 /* Create running */, NULL); function, data, 0 /* Create running */, NULL);