1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Add GLCriticalSection class. Make PluginAPI descendant of GLCriticalSection.

This commit is contained in:
Sergey Lipskiy 2014-09-19 09:47:35 +07:00
parent 43a148b72c
commit 347e69007b
7 changed files with 48 additions and 1 deletions

37
GLCriticalSection.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef GLCRITICALSECTION_H
#define GLCRITICALSECTION_H
#include <mutex> // std::mutex
class GLCriticalSection
{
public:
void lock()
{
m_mtx.lock();
m_locked = true;
}
void unlock()
{
m_locked = false;
m_mtx.unlock();
}
bool isLocked() const {return m_locked;}
protected:
class Lock {
public:
Lock(GLCriticalSection * _pCS) : m_pCS(_pCS) {m_pCS->lock();}
~Lock() {m_pCS->unlock();}
private:
GLCriticalSection * m_pCS;
};
private:
std::mutex m_mtx;
bool m_locked;
};
#endif // GLCRITICALSECTION_H

View File

@ -345,6 +345,7 @@
<ClInclude Include="FrameBuffer.h" />
<ClInclude Include="GBI.h" />
<ClInclude Include="gDP.h" />
<ClInclude Include="GLCriticalSection.h" />
<ClInclude Include="glext.h" />
<ClInclude Include="GLideN64.h" />
<ClInclude Include="gSP.h" />

View File

@ -305,6 +305,9 @@
<ClInclude Include="Log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GLCriticalSection.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">

View File

@ -7,7 +7,9 @@
#include "ZilmarGFX_1_3.h"
#endif
class PluginAPI
#include "GLCriticalSection.h"
class PluginAPI : public GLCriticalSection
{
public:
// Common

View File

@ -15,6 +15,7 @@
void PluginAPI::ProcessDList()
{
Lock lock(this);
RSP_ProcessDList();
}
@ -45,6 +46,7 @@ void PluginAPI::ShowCFB()
void PluginAPI::UpdateScreen()
{
Lock lock(this);
VI_UpdateScreen();
}

View File

@ -4,6 +4,7 @@
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
Lock lock(this);
_initiateGFX(_gfxInfo);
Config_LoadConfig();

View File

@ -14,6 +14,7 @@ BOOL CALLBACK FindToolBarProc( HWND hWnd, LPARAM lParam )
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
Lock lock(this);
_initiateGFX(_gfxInfo);
hWnd = _gfxInfo.hWnd;