Interval Timing 编辑

NSPR defines a platform-dependent type, /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime, for timing intervals of fewer than approximately 6 hours. This chapter describes /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime and the functions that allow you to use it for timing purposes:

Interval Time Type and Constants

All timed functions in NSPR require a parameter that depicts the amount of time allowed to elapse before the operation is declared failed. The type of such arguments is /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRIntervalTime. Such parameters are common in NSPR functions such as those used for I/O operations and operations on condition variables.

NSPR 2.0 provides interval times that are efficient in terms of performance and storage requirements. Conceptually, they are based on free-running counters that increment at a fixed rate without possibility of outside influence (as might be observed if one was using a time-of-day clock that gets reset due to some administrative action). The counters have no fixed epoch and have a finite period. To make use of these counters, the application must declare a point in time, the epoch, and an amount of time elapsed since that epoch, the interval. In almost all cases the epoch is defined as the value of the interval timer at the time it was sampled.

Interval Functions

Interval timing functions are divided into three groups:

Getting the Current Interval and Ticks Per Second

Converting Standard Clock Units to Platform-Dependent Intervals

Converting Platform-Dependent Intervals to Standard Clock Units

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:113 次

字数:5131

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文