]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Thread.hh
new timer class
[chaz/yoink] / src / Moof / Thread.hh
index a5e02254fe4a43b0de769e5b14a4c2eca125beba..274f717b057895c79cd10bacdcd46babcb199d67 100644 (file)
@@ -31,7 +31,7 @@
 
 /**
  * @file Thread.hh
- * Light C++ wrapper around SDL threads.
+ * Light C++ wrapper around the SDL threads API.
  */
 
 #include <boost/function.hpp>
@@ -51,34 +51,33 @@ typedef SDL_Thread* Thread;
 typedef boost::function<int(void)> 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);
 }
This page took 0.021542 seconds and 4 git commands to generate.