ADTF  3.18.2
cHighResTimer

High resolution timer. More...

Public Member Functions

 cHighResTimer ()
 Default constructor.
 
virtual ~cHighResTimer ()
 Destructor.
 
tResult Create (tUInt uiDelay)
 Allocates all resources, registers timer with OS. More...
 
tResult Release ()
 Releases all allocated resources. More...
 
tVoid Sleep (tUInt uiTimeout)
 Pauses the calling thread for a specified time. More...
 
tVoid SleepMicroSeconds (tTimeStamp tmTimeout)
 Pauses the calling thread for a specified time. More...
 

Static Public Member Functions

static tTimeStamp GetTime ()
 Returns the current time in microseconds. More...
 
static tUInt GetMinimumResolution ()
 returns the minimum resolution More...
 
static tUInt GetMaximumResolution ()
 returns the maximum resolution More...
 

Static Private Member Functions

static void TimerProc (tUInt32 uiID, tUInt32 uiMsg, tUInt32 dwUser, tUInt32 dw1, tUInt32 dw2)
 

Detailed Description

High resolution timer.

Provides a better resolution than the standard system timer. Warning: This class is not shared between different objects files and no reference time, therefore the time is not synchronized between different plugins. Be sure to use IReferenceClock instead, when you need a synchronized time. Important for Windows: cHighResTimer is NOT thread safe

Definition at line 22 of file highrestimer.h.

Member Function Documentation

◆ Create()

tResult Create ( tUInt  uiDelay)

Allocates all resources, registers timer with OS.

Parameters
uiDelay[in] The initial delay before the timer will call its handling function, thus the minimum delay before the first Sleep() returns. Must be at least 1.
Returns
ERR_NOERROR if all went well @ [Windows] ERR_INVALID_ARG if timer was not initialized

◆ GetMaximumResolution()

static tUInt GetMaximumResolution ( )
static

returns the maximum resolution

Returns
maximum resolution
Return values
0error case
Attention
only implemented on win32 platforms. on other platforms the default return value is 0

◆ GetMinimumResolution()

static tUInt GetMinimumResolution ( )
static

returns the minimum resolution

Returns
minimum resolution
Return values
0error case
Attention
only implemented on win32 platforms. on other platforms the default return value is 0

◆ GetTime()

static tTimeStamp GetTime ( )
static

Returns the current time in microseconds.

This function will get the high precision time of the cpu frequency ticks.

Returns
The current time in microseconds.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Release()

tResult Release ( )

Releases all allocated resources.

Returns
[Windows]ERR_NOT_INITIALIZED if timer was not initialized.
ERR_NOERROR if all went well.

◆ Sleep()

tVoid Sleep ( tUInt  uiTimeout)

Pauses the calling thread for a specified time.

Remarks
the highresolution time needs to be initialised by calling Create() first, otherwise this function will do nothing.
Parameters
uiTimeout[in] The time to sleep in milliseconds.
Returns
void

◆ SleepMicroSeconds()

tVoid SleepMicroSeconds ( tTimeStamp  tmTimeout)

Pauses the calling thread for a specified time.

Remarks
the highresolution time needs to be initialised by calling Create() first, otherwise this function will do nothing. Since windows doesn't know any method to sleep just some micro seconds the interval is converted to milliseconds and Sleep() is called.
Parameters
tmTimeout[in] The time to sleep in microsecondsseconds.
Returns
void