reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
resip::ResipClock Class Reference

Clock used for timing in the Timer class and possibly other areas. More...

#include <Time.hxx>

Public Member Functions

 ResipClock (void)
 
 ~ResipClock (void)
 

Static Public Member Functions

static uint64_t getTimeMicroSec ()
 Returns the current clock time in microseconds.
 
static uint64_t getTimeMs ()
 Returns the current clock time in milliseconds.
 
static uint64_t getTimeSecs ()
 Returns the current clock time in seconds.
 
static uint64_t getRandomFutureTimeMs (uint64_t futureMs)
 Returns an absolute time in ms that is between 50% and 90% of passed in ms from now.
 
static uint64_t getForever ()
 Infinit time in future.
 
static unsigned getMaxSystemTimeWaitMs (void)
 Some monotonic clock implementations may internally only return 32-bit values that will wrap.
 
static void queryTimerInfo (unsigned &minRes, unsigned &maxRes, unsigned &actualRes, bool &isMonotonic)
 Gets the current clock's minimum, maximum and current/actual timer resolution and returns if the clock is known to be monotonic.
 

Detailed Description

Clock used for timing in the Timer class and possibly other areas.

Depending on the OS and compile settings this clock may not be monotonic. Define _RESIP_MONOTONIC_CLOCK to enable monotonic timers. The precision of this clock is available in microseconds, but the accuracy depends on other factors such as the OS and hardware. The time values returned by this class should be considered independent of any other clock time, including the system time (ie OS date/time,uptime,epoch,etc).

OS Specific notes:

Windows

When _RESIP_MONOTONIC_CLOCK is defined, timeGetTime() is currently used as the underyling time source.
The default resolution/accuracy of this timer on windows is usually the same as the system time clock.
To query resolution information use ResipClock::queryTimerInfo(). timeBeginPeriod() can be used to increase the resolution of the timer and allow for up to 1ms accuracy. This will improve the accuracy of SIP related timers governed by resip::Timer, but also has other OS wide implications, please refer to Microsoft's documenation on timeBeginPeriod() for more information.

When _RESIP_MONOTONIC_CLOCK is not defined, GetSystemTime is used as the underlying time source. This value can jump forward or backward (not monotonic) if the OS system time is adjusted. The default resolution of this timer is the current system clock interrupt time and cannot be set to a higher resolution. The resolution has been observed at approx 15ms on XP and 1ms on Vista.

POSIX

When _RESIP_MONOTONIC_CLOCK is defined, clock_gettime() is used with the CLOCK_MONOTONIC clock.

When _RESIP_MONOTONIC_CLOCK is not defined, gettimeofday() is used as the underyling clock.

OS X

A monotonic clock is currently not implemented for OS X. There appear to be a couple of choices. http://www.wand.net.nz/~smr26/wordpress/2009/01/19/monotonic-time-in-mac-os-x/ http://www.meandmark.com/timing.pdf http://developer.apple.com/qa/qa2004/qa1398.html

See also
resiprocate.org devlist discussion "Timers: why system time?";

Definition at line 53 of file Time.hxx.

Constructor & Destructor Documentation

◆ ResipClock()

ResipClock::ResipClock ( void  )

Definition at line 37 of file Time.cxx.

◆ ~ResipClock()

ResipClock::~ResipClock ( void  )

Definition at line 41 of file Time.cxx.

Member Function Documentation

◆ getForever()

uint64_t ResipClock::getForever ( )
static

Infinit time in future.

Definition at line 245 of file Time.cxx.

◆ getMaxSystemTimeWaitMs()

static unsigned resip::ResipClock::getMaxSystemTimeWaitMs ( void  )
inlinestatic

Some monotonic clock implementations may internally only return 32-bit values that will wrap.

See also
Timer::getMaxSystemTimeWaitMs()

Definition at line 92 of file Time.hxx.

◆ getRandomFutureTimeMs()

uint64_t ResipClock::getRandomFutureTimeMs ( uint64_t  futureMs)
static

Returns an absolute time in ms that is between 50% and 90% of passed in ms from now.

Definition at line 256 of file Time.cxx.

◆ getTimeMicroSec()

static uint64_t resip::ResipClock::getTimeMicroSec ( )
inlinestatic

Returns the current clock time in microseconds.

Definition at line 61 of file Time.hxx.

◆ getTimeMs()

static uint64_t resip::ResipClock::getTimeMs ( )
inlinestatic

Returns the current clock time in milliseconds.

Definition at line 69 of file Time.hxx.

◆ getTimeSecs()

static uint64_t resip::ResipClock::getTimeSecs ( )
inlinestatic

Returns the current clock time in seconds.

Definition at line 76 of file Time.hxx.

◆ queryTimerInfo()

void ResipClock::queryTimerInfo ( unsigned &  minRes,
unsigned &  maxRes,
unsigned &  actualRes,
bool &  isMonotonic 
)
static

Gets the current clock's minimum, maximum and current/actual timer resolution and returns if the clock is known to be monotonic.

If min, max or actual return 0 then that information is not available. min max and actual are in units of microseconds.

Definition at line 275 of file Time.cxx.


The documentation for this class was generated from the following files: