diff options
Diffstat (limited to 'src/common/thread.c')
-rw-r--r-- | src/common/thread.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/common/thread.c b/src/common/thread.c index 4f73aa9b3..bba56e7eb 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -17,7 +17,7 @@ #ifdef WIN32 # include "../common/winapi.h" # define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -# define __thread __declspec( thread ) +# define __thread __declspec( thread ) #else # include <stdlib.h> # include <unistd.h> @@ -28,8 +28,8 @@ #endif // When Compiling using MSC (on win32..) we know we have support in any case! -#ifdef _MSC_VER -#define HAS_TLS +#ifdef _MSC_VER +#define HAS_TLS #endif @@ -40,7 +40,7 @@ struct rAthread { RATHREAD_PRIO prio; rAthreadProc proc; - void *param; + void *param; #ifdef WIN32 HANDLE hThread; @@ -82,9 +82,9 @@ void rathread_init(){ void rathread_final(){ register unsigned int i; - // Unterminated Threads Left? + // Unterminated Threads Left? // Should'nt happen .. - // Kill 'em all! + // Kill 'em all! // for(i = 1; i < RA_THREADS_MAX; i++){ if(l_threads[i].proc != NULL){ @@ -116,12 +116,12 @@ static void *_raThreadMainRedirector( void *p ){ // Update myID @ TLS to right id. #ifdef HAS_TLS - g_rathread_ID = ((rAthread)p)->myID; + g_rathread_ID = ((rAthread)p)->myID; #endif #ifndef WIN32 // When using posix threads - // the threads inherits the Signal mask from the thread which's spawned + // the threads inherits the Signal mask from the thread which's spawned // this thread // so we've to block everything we dont care about. sigemptyset(&set); @@ -136,7 +136,7 @@ static void *_raThreadMainRedirector( void *p ){ ret = ((rAthread)p)->proc( ((rAthread)p)->param ) ; -#ifdef WIN32 +#ifdef WIN32 CloseHandle( ((rAthread)p)->hThread ); #endif @@ -154,7 +154,7 @@ static void *_raThreadMainRedirector( void *p ){ /// /// API Level -/// +/// rAthread rathread_create( rAthreadProc entryPoint, void *param ){ return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL ); }//end: rathread_create() @@ -175,7 +175,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta szStack += tmp; - // Get a free Thread Slot. + // Get a free Thread Slot. for(i = 0; i < RA_THREADS_MAX; i++){ if(l_threads[i].proc == NULL){ handle = &l_threads[i]; @@ -223,7 +223,6 @@ void rathread_destroy ( rAthread handle ){ if( pthread_cancel( handle->hThread ) == 0){ // We have to join it, otherwise pthread wont re-cycle its internal ressources assoc. with this thread. - // pthread_join( handle->hThread, NULL ); // Tell our manager to release ressources ;) @@ -236,10 +235,10 @@ rAthread rathread_self( ){ #ifdef HAS_TLS rAthread handle = &l_threads[g_rathread_ID]; - if(handle->proc != NULL) // entry point set, so its used! + if(handle->proc != NULL) // entry point set, so its used! return handle; #else - // .. so no tls means we have to search the thread by its api-handle .. + // .. so no tls means we have to search the thread by its api-handle .. int i; #ifdef WIN32 @@ -257,13 +256,13 @@ rAthread rathread_self( ){ #endif - return NULL; + return NULL; }//end: rathread_self() int rathread_get_tid(){ -#ifdef HAS_TLS +#ifdef HAS_TLS return g_rathread_ID; #else // todo @@ -286,7 +285,7 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ){ // #ifdef WIN32 WaitForSingleObject(handle->hThread, INFINITE); - return true; + return true; #else if(pthread_join(handle->hThread, out_exitCode) == 0) return true; @@ -297,8 +296,8 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ){ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ){ - handle->prio = RAT_PRIO_NORMAL; - //@TODO + handle->prio = RAT_PRIO_NORMAL; + //@TODO }//end: rathread_prio_set() @@ -308,9 +307,9 @@ RATHREAD_PRIO rathread_prio_get( rAthread handle){ void rathread_yield(){ -#ifdef WIN32 +#ifdef WIN32 SwitchToThread(); #else sched_yield(); -#endif +#endif }//end: rathread_yield() |