add EnterTimeCriticalSection(), ExitTimeCriticalSection()
This commit is contained in:
@@ -42,6 +42,12 @@ public:
|
||||
/* Re-exec the game. If this is implemented, it doesn't return. */
|
||||
virtual void RestartProgram() { }
|
||||
|
||||
/* Call this to temporarily enter a high-priority or realtime scheduling (depending
|
||||
* on the implementation) mode. This is used to improve timestamp accuracy. Do as
|
||||
* little as possible in this mode; hanging in it might hang the system entirely. */
|
||||
virtual void EnterTimeCriticalSection() { }
|
||||
virtual void ExitTimeCriticalSection() { }
|
||||
|
||||
protected:
|
||||
virtual void MessageBoxErrorPrivate( CString sMessage, CString ID ) { printf("Error: %s\n", sMessage.c_str()); }
|
||||
virtual void MessageBoxOKPrivate( CString sMessage, CString ID ) {}
|
||||
|
||||
@@ -12,9 +12,16 @@
|
||||
#include "archutils/win32/RestartProgram.h"
|
||||
#include "ProductInfo.h"
|
||||
|
||||
#include "RageThreads.h"
|
||||
ArchHooks_Win32::ArchHooks_Win32()
|
||||
{
|
||||
SetUnhandledExceptionFilter(CrashHandler);
|
||||
TimeCritMutex = new RageMutex;
|
||||
}
|
||||
|
||||
ArchHooks_Win32::~ArchHooks_Win32()
|
||||
{
|
||||
delete TimeCritMutex;
|
||||
}
|
||||
|
||||
void ArchHooks_Win32::DumpDebugInfo()
|
||||
@@ -180,9 +187,24 @@ void ArchHooks_Win32::RestartProgram()
|
||||
Win32RestartProgram();
|
||||
}
|
||||
|
||||
void ArchHooks_Win32::EnterTimeCriticalSection()
|
||||
{
|
||||
TimeCritMutex->Lock();
|
||||
|
||||
OldThreadPriority = GetThreadPriority( GetCurrentThread() );
|
||||
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
|
||||
}
|
||||
|
||||
void ArchHooks_Win32::ExitTimeCriticalSection()
|
||||
{
|
||||
SetThreadPriority( GetCurrentThread(), OldThreadPriority );
|
||||
OldThreadPriority = 0;
|
||||
TimeCritMutex->Unlock();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002-2003 by the person(s) listed below. All rights reserved.
|
||||
* Copyright (c) 2002-2004 by the person(s) listed below. All rights reserved.
|
||||
*
|
||||
* Glenn Maynard
|
||||
* Chris Danford
|
||||
|
||||
@@ -2,16 +2,24 @@
|
||||
#define ARCH_HOOKS_WIN32_H
|
||||
|
||||
#include "ArchHooks.h"
|
||||
class RageMutex;
|
||||
|
||||
class ArchHooks_Win32: public ArchHooks
|
||||
{
|
||||
public:
|
||||
ArchHooks_Win32();
|
||||
~ArchHooks_Win32();
|
||||
void DumpDebugInfo();
|
||||
void MessageBoxOKPrivate( CString sMessage, CString ID );
|
||||
void MessageBoxErrorPrivate( CString error, CString ID );
|
||||
MessageBoxResult MessageBoxAbortRetryIgnorePrivate( CString sMessage, CString ID );
|
||||
MessageBoxResult MessageBoxRetryCancelPrivate( CString sMessage, CString ID );
|
||||
void RestartProgram();
|
||||
|
||||
int OldThreadPriority;
|
||||
RageMutex *TimeCritMutex;
|
||||
void EnterTimeCriticalSection();
|
||||
void ExitTimeCriticalSection();
|
||||
};
|
||||
|
||||
#undef ARCH_HOOKS
|
||||
|
||||
Reference in New Issue
Block a user