Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Functions | Variables
whrt.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/os/win/whrt/whrt.h"
#include <process.h>
#include "lib/sysdep/cpu.h"
#include "lib/sysdep/os/win/wutil.h"
#include "lib/sysdep/os/win/winit.h"
#include "lib/sysdep/acpi.h"
#include "lib/bits.h"
#include "lib/sysdep/os/win/whrt/counter.h"

Go to the source code of this file.

Classes

struct  TimerState
 stores all timer state shared between readers and the update thread. More...
 

Namespaces

 ERR
 

Introduction


 

Functions

 WINIT_REGISTER_EARLY_INIT2 (whrt_Init)
 
 WINIT_REGISTER_LATE_SHUTDOWN (whrt_Shutdown)
 
static Status ActivateCounter (ICounter *counter)
 
static ICounterGetNextBestSafeCounter ()
 
static void InitCounter ()
 
static void ShutdownCounter ()
 
static u64 Counter ()
 
static u64 CounterDelta (u64 oldCounter, u64 newCounter)
 
double whrt_Resolution ()
 
static __declspec (align(64)) TimerState timerStates[2]
 
static void UpdateTimerState ()
 
double whrt_Time ()
 
static unsigned __stdcall UpdateThread (void *data)
 
static Status InitUpdateThread ()
 
static void ShutdownUpdateThread ()
 
static Status whrt_Init ()
 
static Status whrt_Shutdown ()
 

Variables

const Status ERR::WHRT_COUNTER_UNSAFE = 140000
 
static ICountercounter
 
static double nominalFrequency
 
static double resolution
 
static size_t counterBits
 
static u64 counterMask
 
static volatile TimerState
*volatile 
ts = &timerStates[0]
 
static volatile TimerState
*volatile 
ts2 = &timerStates[1]
 
static const DWORD UPDATE_INTERVAL_MS = 1000
 
static HANDLE hExitEvent
 
static HANDLE hUpdateThread
 

Function Documentation

static __declspec ( align(64)  )
static
static Status ActivateCounter ( ICounter counter)
inlinestatic

Definition at line 54 of file whrt.cpp.

static u64 Counter ( )
inlinestatic

Definition at line 129 of file whrt.cpp.

static u64 CounterDelta ( u64  oldCounter,
u64  newCounter 
)
inlinestatic
Returns
difference [ticks], taking rollover into account. (time-critical, so it's not called through ICounter.)

Definition at line 138 of file whrt.cpp.

static ICounter* GetNextBestSafeCounter ( )
static
Returns
the newly created and unique instance of the next best counter that is deemed safe, or 0 if all have already been created.

Definition at line 68 of file whrt.cpp.

static void InitCounter ( )
static

Definition at line 103 of file whrt.cpp.

static Status InitUpdateThread ( )
inlinestatic

Definition at line 257 of file whrt.cpp.

static void ShutdownCounter ( )
static

Definition at line 124 of file whrt.cpp.

static void ShutdownUpdateThread ( )
inlinestatic

Definition at line 278 of file whrt.cpp.

static unsigned __stdcall UpdateThread ( void *  data)
static

Definition at line 240 of file whrt.cpp.

static void UpdateTimerState ( )
static

Definition at line 190 of file whrt.cpp.

static Status whrt_Init ( )
static

Definition at line 293 of file whrt.cpp.

double whrt_Resolution ( )

Definition at line 143 of file whrt.cpp.

static Status whrt_Shutdown ( )
static

Definition at line 308 of file whrt.cpp.

double whrt_Time ( )

Definition at line 208 of file whrt.cpp.

WINIT_REGISTER_EARLY_INIT2 ( whrt_Init  )
WINIT_REGISTER_LATE_SHUTDOWN ( whrt_Shutdown  )

Variable Documentation

ICounter* counter
static

Definition at line 96 of file whrt.cpp.

size_t counterBits
static

Definition at line 100 of file whrt.cpp.

u64 counterMask
static

Definition at line 101 of file whrt.cpp.

HANDLE hExitEvent
static

Definition at line 237 of file whrt.cpp.

HANDLE hUpdateThread
static

Definition at line 238 of file whrt.cpp.

double nominalFrequency
static

Definition at line 98 of file whrt.cpp.

double resolution
static

Definition at line 99 of file whrt.cpp.

volatile TimerState* volatile ts = &timerStates[0]
static

Definition at line 187 of file whrt.cpp.

volatile TimerState* volatile ts2 = &timerStates[1]
static

Definition at line 188 of file whrt.cpp.

const DWORD UPDATE_INTERVAL_MS = 1000
static

Definition at line 235 of file whrt.cpp.