interval_timing.rst (2801B)
1 NSPR defines a platform-dependent type, :ref:`PRIntervalTime`, for timing 2 intervals of fewer than approximately 6 hours. This chapter describes 3 :ref:`PRIntervalTime` and the functions that allow you to use it for timing 4 purposes: 5 6 - `Interval Time Type and 7 Constants <#Interval_Time_Type_and_Constants>`__ 8 - `Interval Functions <#Interval_Functions>`__ 9 10 .. _Interval_Time_Type_and_Constants: 11 12 Interval Time Type and Constants 13 -------------------------------- 14 15 All timed functions in NSPR require a parameter that depicts the amount 16 of time allowed to elapse before the operation is declared failed. The 17 type of such arguments is :ref:`PRIntervalTime`. Such parameters are common 18 in NSPR functions such as those used for I/O operations and operations 19 on condition variables. 20 21 NSPR 2.0 provides interval times that are efficient in terms of 22 performance and storage requirements. Conceptually, they are based on 23 free-running counters that increment at a fixed rate without possibility 24 of outside influence (as might be observed if one was using a 25 time-of-day clock that gets reset due to some administrative action). 26 The counters have no fixed epoch and have a finite period. To make use 27 of these counters, the application must declare a point in time, the 28 epoch, and an amount of time elapsed since that **epoch**, the 29 **interval**. In almost all cases the epoch is defined as the value of 30 the interval timer at the time it was sampled. 31 32 - :ref:`PRIntervalTime` 33 34 .. _Interval_Functions: 35 36 Interval Functions 37 ------------------ 38 39 Interval timing functions are divided into three groups: 40 41 - `Getting the Current Interval and Ticks Per 42 Second <#Getting_the_Current_Interval_and_Ticks_Per_Second>`__ 43 - `Converting Standard Clock Units to Platform-Dependent 44 Intervals <#Converting_Standard_Clock_Units_to_Platform-Dependent_Intervals>`__ 45 - `Converting Platform-Dependent Intervals to Standard Clock 46 Units <#Converting_Platform-Dependent_Intervals_to_Standard_Clock_Units>`__ 47 48 .. _Getting_the_Current_Interval_and_Ticks_Per_Second: 49 50 Getting the Current Interval and Ticks Per Second 51 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 52 53 - :ref:`PR_IntervalNow` 54 - :ref:`PR_TicksPerSecond` 55 56 .. _Converting_Standard_Clock_Units_to_Platform-Dependent_Intervals: 57 58 Converting Standard Clock Units to Platform-Dependent Intervals 59 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 61 - :ref:`PR_SecondsToInterval` 62 - :ref:`PR_MillisecondsToInterval` 63 - :ref:`PR_MicrosecondsToInterval` 64 65 .. _Converting_Platform-Dependent_Intervals_to_Standard_Clock_Units: 66 67 Converting Platform-Dependent Intervals to Standard Clock Units 68 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 70 - :ref:`PR_IntervalToSeconds` 71 - :ref:`PR_IntervalToMilliseconds` 72 - :ref:`PR_IntervalToMicroseconds`