/**
* @file Thread.hh
- * Light C++ wrapper around SDL threads.
+ * Light C++ wrapper around the SDL threads API.
*/
#include <boost/function.hpp>
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);
}
// 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);
}