boost::asio for resource manager threads
This commit is contained in:
1 parent
06652bfa0d
commit
a68e798a89
7 files changed
+48
-10
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user