ArchHooks::GetMicrosecondsSinceStart (not used yet)
This commit is contained in:
@@ -1,20 +1,6 @@
|
||||
#ifndef ARCH_HOOKS_H
|
||||
#define ARCH_HOOKS_H
|
||||
|
||||
/*
|
||||
* I'm undecided about when it's a good idea to use arch; I'm experimenting
|
||||
* a bit.
|
||||
*
|
||||
* This arch driver is simply called at various important points, to let
|
||||
* architectures do things. Windows can use this to start up the crash
|
||||
* handler and to output Windows-specific debug information, for example.
|
||||
*
|
||||
* This class should have one-way data transfer only: functions are called,
|
||||
* they may do something, and no data is returned. (We don't want to have
|
||||
* to deal with error handling and so on when using these functions.)
|
||||
*
|
||||
* This class is constructed at the very start of the program.
|
||||
*/
|
||||
class ArchHooks
|
||||
{
|
||||
public:
|
||||
@@ -36,6 +22,9 @@ public:
|
||||
virtual void ExitTimeCriticalSection() { }
|
||||
|
||||
virtual void SetTime( tm newtime ) { }
|
||||
|
||||
/* */
|
||||
virtual int64_t GetMicrosecondsSinceStart() = 0;
|
||||
};
|
||||
|
||||
ArchHooks *MakeArchHooks();
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "archutils/win32/VideoDriverInfo.h"
|
||||
#include "archutils/win32/WindowsResources.h"
|
||||
|
||||
#include <mmsystem.h>
|
||||
#pragma comment(lib, "winmm.lib") // for GetMicrosecondsSinceStart
|
||||
|
||||
ArchHooks_Win32::ArchHooks_Win32()
|
||||
{
|
||||
SetUnhandledExceptionFilter(CrashHandler);
|
||||
@@ -182,6 +185,20 @@ void ArchHooks_Win32::SetTime( tm newtime )
|
||||
SetLocalTime( &st );
|
||||
}
|
||||
|
||||
int64_t ArchHooks_Win32::GetMicrosecondsSinceStart()
|
||||
{
|
||||
static bool bInitialized;
|
||||
static DWORD iStartTime;
|
||||
if( !bInitialized )
|
||||
{
|
||||
timeBeginPeriod( 1 );
|
||||
bInitialized = true;
|
||||
iStartTime = timeGetTime();
|
||||
}
|
||||
|
||||
return (timeGetTime() - iStartTime) * 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void EnterTimeCriticalSection();
|
||||
void ExitTimeCriticalSection();
|
||||
void SetTime( tm newtime );
|
||||
int64_t GetMicrosecondsSinceStart();
|
||||
|
||||
private:
|
||||
void CheckVideoDriver();
|
||||
|
||||
Reference in New Issue
Block a user