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

+5 -3
View File
@@ -25,12 +25,12 @@ TResourceManager* ResourceManager;
void TResourceManager::Update(cardinal timer)
{
FuncListMutex.lock();
//FuncListMutex.lock();
SoundManager.Update(timer);
GUIManager.Update(timer);
/*
if (MainThreadAsyncFunctionArr.size() != 0)
{
MainThreadAsyncFunctionArr[0]();
@@ -52,7 +52,9 @@ void TResourceManager::Update(cardinal timer)
itr->LockerPtr->unlock();
}
FuncListMutex.unlock();
FuncListMutex.unlock();*/
MainThreadIoService.run();
MainThreadIoService.reset();
}
TResourceManager::~TResourceManager()
+13
View File
@@ -3,6 +3,8 @@
namespace SE
{
boost::asio::io_service MainThreadIoService;
#ifndef UTILS_ENGINE
void AssertIfInMainThread()
{
@@ -22,6 +24,7 @@ namespace SE
void PerformInMainThreadAsync(boost::function<void()> f)
{
/*
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
{
f();
@@ -29,7 +32,17 @@ namespace SE
else
{
ResourceManager->MainThreadAsyncFunctionArr.push_back(f);
}*/
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
{
f();
}
else
{
MainThreadIoService.dispatch(f);
}
}
#endif
+3 -1
View File
@@ -8,6 +8,8 @@ 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(HWND hwnd, int& width, int& height)
{
RECT rc;
@@ -32,5 +34,5 @@ int GetWindowHeight(HWND hwnd)
return rc.bottom;
}
*/
} //namespace SE