boost::asio for resource manager threads

This commit is contained in:
vladislav.khorev committed 2013-02-20 05:10:38 +00:00
1 parent 06652bfa0d
commit a68e798a89
7 files changed
+48 -10

No files matched your search

+6 -1
View File
@@ -1,13 +1,18 @@
#ifndef THREAD_UTILS_H_INCLUDED
#define THREAD_UTILS_H_INCLUDED
#include "boost/asio.hpp"
#include "boost/signal.hpp"
#include "boost/thread.hpp"
namespace SE
{
extern boost::asio::io_service MainThreadIoService;
#ifndef UTILS_ENGINE
/*
struct TFuncToPerform
{
private:
@@ -23,7 +28,7 @@ namespace SE
std::shared_ptr<boost::mutex> LockerPtr;
boost::function<void()> Func;
};
};*/
void AssertIfInMainThread();
+15 -1
View File
@@ -24,7 +24,21 @@ namespace SE
template<typename RETURNTYPE>
RETURNTYPE PerformInMainThread(boost::function<RETURNTYPE()> f)
{
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
{
return f();
}
else
{
RETURNTYPE result;
boost::function<void()> cover_f = [&result, f]() { result = f(); };
MainThreadIoService.post(cover_f);
return result;
}
/*
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
{
return f();
@@ -57,7 +71,7 @@ namespace SE
return result;
}
}*/
}
} //namespace SE
+3 -1
View File
@@ -15,10 +15,12 @@ Here goes all functions that are platform-specific
When I make iOS/Mac/Linux port, I will make same API pair h/cpp
*/
//Not in use, wow
/*
void GetWindowWidthHeight(int& width, int& height);
int GetWindowWidth();
int GetWindowHeight();
int GetWindowHeight();*/
} //namespace SE