X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FThread.hh;h=274f717b057895c79cd10bacdcd46babcb199d67;hp=a5e02254fe4a43b0de769e5b14a4c2eca125beba;hb=33842c860fe18ca8cf087905992885687434320c;hpb=6dd7ae54e742339cc49e640d1076a310a0f4eedd diff --git a/src/Moof/Thread.hh b/src/Moof/Thread.hh index a5e0225..274f717 100644 --- a/src/Moof/Thread.hh +++ b/src/Moof/Thread.hh @@ -31,7 +31,7 @@ /** * @file Thread.hh - * Light C++ wrapper around SDL threads. + * Light C++ wrapper around the SDL threads API. */ #include @@ -51,34 +51,33 @@ typedef SDL_Thread* Thread; typedef boost::function Function; -int detach_(void* arg) +inline int detach_(void* arg) { - Function function = *(Function*)arg; - int ret = function(); + //Function function = *(Function*)arg; + int code = (*(Function*)arg)(); delete (Function*)arg; - return ret; + return code; } -Thread detachFunction(const Function& function) +inline Thread detachFunction(const Function& function) { - Thread thread; Function* fcopy = new Function(function); + Thread thread = SDL_CreateThread(detach_, (void*)fcopy); - thread = SDL_CreateThread(detach_, (void*)fcopy); if (thread == 0) delete fcopy; return thread; } -int waitOnThread(Thread thread) +inline int waitOnThread(Thread thread) { int i; SDL_WaitThread(thread, &i); return i; } -void killThread(Thread thread) +inline void killThread(Thread thread) { SDL_KillThread(thread); } @@ -88,12 +87,12 @@ void killThread(Thread thread) // The identifier function returns a unique integer for the calling thread. // -unsigned int getThreadIdentifier() +inline unsigned getThreadIdentifier() { return SDL_ThreadID(); } -unsigned int getThreadIdentifier(Thread thread) +inline unsigned getThreadIdentifier(Thread thread) { return SDL_GetThreadID(thread); }